Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to launch a console application from a form application Pin
nhack6-Jun-09 21:24
nhack6-Jun-09 21:24 
GeneralRe: How to launch a console application from a form application Pin
Alan N7-Jun-09 0:42
Alan N7-Jun-09 0:42 
GeneralRe: How to launch a console application from a form application Pin
nhack7-Jun-09 1:22
nhack7-Jun-09 1:22 
Questionany advantage by using get/set in c#? Pin
Seraph_summer6-Jun-09 10:43
Seraph_summer6-Jun-09 10:43 
AnswerRe: any advantage by using get/set in c#? Pin
0x3c06-Jun-09 10:53
0x3c06-Jun-09 10:53 
AnswerRe: any advantage by using get/set in c#? Pin
I Believe In GOD6-Jun-09 11:17
I Believe In GOD6-Jun-09 11:17 
AnswerRe: any advantage by using get/set in c#? Pin
Troy Russell6-Jun-09 11:18
Troy Russell6-Jun-09 11:18 
AnswerRe: any advantage by using get/set in c#? Pin
FocusedWolf6-Jun-09 11:32
FocusedWolf6-Jun-09 11:32 
Properties have a special use if your making a custom control with custom properties.

#region Color HighlightColor

private Color highlightColor = Color.Yellow;
[DefaultValue(typeof(Color), "Yellow")]
public Color HighlightColor
{
get { return highlightColor; }
set
{
if (highlightColor != value)
{
highlightColor = value;
this.Invalidate();
}
}
}

public bool ShouldSerializeHighlightColor()
{
return highlightColor != Color.Yellow;
}

public void ResetHighlightColor()
{
HighlightColor = Color.Yellow;
}

#endregion


here's one from a control i'm working on... the attribute for defaultvalue and the ShouldSerialize##"Property Name" Reset##"Property Name" functions are specially called by the visual studio ide... so when you have your control on the designer, and you play with a setting... you can do stuff like right click it and hit "Reset"... also the shouldSerialze function is checked for if the designer needs to save that setting to the .designer.cs file. This way the designer doesnt have to serialze a dozen default values... which probably improves performance or whatnot... looks nicer to when you gotta go in the designer file... i forget if the defaultvalue attribute means so when you type a value in the propertygrid, that if its the default value in that attribute, that the ide shows regular font or bold, that you changed it from default,...

So properties are nice if your making a custom control. Otherwise, properties are handy for controlling what comes in and leaves your class...

like have a getOnly type property like:

public int Something {
get { return something; }
}

or here's checking input:

public string SomeOtherThing {
get { return someOtherThing; }
set
{
if (!String.IsNullOrEmpty(value))
someOtherThing = value;
}
}

.... so i see your point... i mean in C++ the method was with functions to do the same job. So the only advantage of a property is that the IDE can draw a nice little icon when it detects one in your class... like i mean intellisense... other then that, and all programmers already expect to play with properties to set settings, that they have no purpose. Practically a bloated feature if we just look at C# as the language... but ya, their good for the vs.net designer when plopping controls on a form :P
AnswerRe: any advantage by using get/set in c#? Pin
Troy Russell6-Jun-09 12:10
Troy Russell6-Jun-09 12:10 
AnswerRe: any advantage by using get/set in c#? Pin
Christian Graus6-Jun-09 12:51
protectorChristian Graus6-Jun-09 12:51 
AnswerRe: any advantage by using get/set in c#? Pin
Henry Minute7-Jun-09 0:48
Henry Minute7-Jun-09 0:48 
Questionhttp://www.sourceforge.net/ Pin
I Believe In GOD6-Jun-09 10:29
I Believe In GOD6-Jun-09 10:29 
AnswerRe: http://www.sourceforge.net/ Pin
Seraph_summer6-Jun-09 10:38
Seraph_summer6-Jun-09 10:38 
GeneralRe: http://www.sourceforge.net/ Pin
I Believe In GOD6-Jun-09 10:49
I Believe In GOD6-Jun-09 10:49 
AnswerRe: http://www.sourceforge.net/ Pin
Yusuf6-Jun-09 11:19
Yusuf6-Jun-09 11:19 
GeneralRe: http://www.sourceforge.net/ Pin
I Believe In GOD6-Jun-09 11:55
I Believe In GOD6-Jun-09 11:55 
QuestionPlease please please please ... Pin
IceWater426-Jun-09 9:55
IceWater426-Jun-09 9:55 
AnswerRe: Please please please please ... Pin
Dave Kreskowiak6-Jun-09 10:15
mveDave Kreskowiak6-Jun-09 10:15 
GeneralRe: Please please please please ... Pin
IceWater426-Jun-09 22:02
IceWater426-Jun-09 22:02 
GeneralRe: Please please please please ... Pin
Dave Kreskowiak7-Jun-09 7:15
mveDave Kreskowiak7-Jun-09 7:15 
AnswerRe: Please please please please ... Pin
EliottA6-Jun-09 12:59
EliottA6-Jun-09 12:59 
AnswerRe: Please please please please ... Pin
FocusedWolf6-Jun-09 18:05
FocusedWolf6-Jun-09 18:05 
GeneralRe: Please please please please ... Pin
IceWater426-Jun-09 21:42
IceWater426-Jun-09 21:42 
GeneralRe: Please please please please ... Pin
FocusedWolf7-Jun-09 9:09
FocusedWolf7-Jun-09 9:09 
GeneralRe: Please please please please ... Pin
David OBrien12-Oct-09 4:12
David OBrien12-Oct-09 4:12 

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.