Click here to Skip to main content
15,914,642 members
Home / Discussions / C#
   

C#

 
GeneralRe: New form variables passing Pin
Colin Angus Mackay10-May-09 3:22
Colin Angus Mackay10-May-09 3:22 
GeneralRe: New form variables passing Pin
michaelgr110-May-09 3:52
michaelgr110-May-09 3:52 
GeneralRe: New form variables passing Pin
N a v a n e e t h10-May-09 4:34
N a v a n e e t h10-May-09 4:34 
GeneralRe: New form variables passing Pin
Henry Minute10-May-09 5:09
Henry Minute10-May-09 5:09 
GeneralRe: New form variables passing Pin
michaelgr110-May-09 6:47
michaelgr110-May-09 6:47 
GeneralRe: New form variables passing Pin
Henry Minute10-May-09 6:58
Henry Minute10-May-09 6:58 
GeneralRe: New form variables passing Pin
michaelgr110-May-09 7:04
michaelgr110-May-09 7:04 
GeneralRe: New form variables passing Pin
Henry Minute10-May-09 7:23
Henry Minute10-May-09 7:23 
michaelgr1 wrote:
What is the difference in declarations in Visual studio 2008 and 2005. Why it 2008 we don't have to write this code?


In Visual Studio 2008, for simple properties you only have to write it as I showed the first time, VS does everything else to make it behave like the second example I gave, behind the scenes. In VS2008 they are called Auto-Implemented Properties.


michaelgr1 wrote:
BTW, I wrote only:
public string QueryString;
Is it enough? or i still need the constructor and why?


What you have done, should work. BUT it is considered to be bad programming in OOP (Object Oriented Programming, just in case you didn't know). It breaks several of the 'rules', most notably the Data Hiding principle. Google on that for a more detailed explanation.

For now, though, consider the case that you wanted something to happen automatically every time QueryString changed. With your method it will be very, very difficult. With the second method I posted it would be very easy, and what's more it would be less likely to break some other part of the code.

Like this:
private string queryString;
public string QueryString
{
    get
    {
        return this.queryString;
    }

    set
    {
        this.queryString = value;
        this.MyDoSomethingWonderfulWithQueryStringMethod();
    }
}


If you later had to change the way that MyDoSomethingWonderfulWithQueryStringMethod() works, you can, and as I said it is unlikely to break anything else.

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

Questionhow to update the datas present in textbox to gridview control (gui) ,SQL2005 Pin
Mads11510-May-09 0:42
Mads11510-May-09 0:42 
AnswerRe: how to update the datas present in textbox to gridview control (gui) ,SQL2005 Pin
Noctris10-May-09 12:06
Noctris10-May-09 12:06 
QuestionProblem in Printing a persian(or arabic) document Pin
Roshanakak9-May-09 19:18
Roshanakak9-May-09 19:18 
AnswerRe: Problem in Printing a persian(or arabic) document Pin
Ramin Barati19-May-09 8:50
Ramin Barati19-May-09 8:50 
QuestionPreferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 12:22
harold aptroot9-May-09 12:22 
AnswerRe: Preferred way of bytes to kbytes conversion? Pin
Christian Graus9-May-09 12:28
protectorChristian Graus9-May-09 12:28 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 12:32
harold aptroot9-May-09 12:32 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Christian Graus9-May-09 12:38
protectorChristian Graus9-May-09 12:38 
AnswerRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 12:37
sitebuilderLuc Pattyn9-May-09 12:37 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 12:41
harold aptroot9-May-09 12:41 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 12:59
sitebuilderLuc Pattyn9-May-09 12:59 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
harold aptroot9-May-09 13:06
harold aptroot9-May-09 13:06 
GeneralRe: Preferred way of bytes to kbytes conversion? Pin
Luc Pattyn9-May-09 13:09
sitebuilderLuc Pattyn9-May-09 13:09 
GeneralEnabling Secondry Monitor using C# Pin
jonesyx9-May-09 9:24
jonesyx9-May-09 9:24 
GeneralRe: Enabling Secondry Monitor using C# Pin
Luc Pattyn9-May-09 12:29
sitebuilderLuc Pattyn9-May-09 12:29 
Questiondatagrid copy Pin
michaelgr19-May-09 7:44
michaelgr19-May-09 7:44 
AnswerRe: datagrid copy Pin
Mycroft Holmes9-May-09 14:32
professionalMycroft Holmes9-May-09 14:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.