Click here to Skip to main content
15,891,607 members
Home / Discussions / C#
   

C#

 
GeneralRe: Exception Handling . To throw or not to throw? Pin
bzurer17-Feb-04 1:50
bzurer17-Feb-04 1:50 
GeneralRe: Exception Handling . To throw or not to throw? Pin
Jonathan de Halleux17-Feb-04 2:09
Jonathan de Halleux17-Feb-04 2:09 
GeneralRe: Exception Handling . To throw or not to throw? Pin
bzurer17-Feb-04 1:56
bzurer17-Feb-04 1:56 
AnswerRe: Exception Handling . To throw or not to throw? Pin
Heath Stewart17-Feb-04 5:04
protectorHeath Stewart17-Feb-04 5:04 
GeneralAccessing properties as an array Pin
Omega50116-Feb-04 21:28
Omega50116-Feb-04 21:28 
GeneralRe: Accessing properties as an array Pin
thomasa16-Feb-04 23:32
thomasa16-Feb-04 23:32 
GeneralRe: Accessing properties as an array Pin
Heath Stewart17-Feb-04 5:11
protectorHeath Stewart17-Feb-04 5:11 
GeneralRe: Accessing properties as an array Pin
OmegaSupreme17-Feb-04 0:46
OmegaSupreme17-Feb-04 0:46 
Do it just like you wrote :

<br />
	public string[] Property{ <br />
		get{return sProperty;}<br />
		set{sProperty = value;}<br />
	}<br />


and access it like so

<br />
Object o = new Object();<br />
		o.Property = new String[] {"foo", "bar"};<br />
		Console.WriteLine("{0} {1}", o.Property[0], o.Property[1]);<br />


another trick is to use default properties[^]

write you property like this

<br />
	public string this[int index] {<br />
		get { return sProperty[index]; }<br />
		set { sProperty[index] = value; }<br />
	}<br />


and access like this

<br />
Object o = new Object();<br />
		o.Property = new String[2];<br />
		o[0]  = "foo";<br />
		o[1] = "bar";<br />
		Console.WriteLine("{0} {1}", o[0], o[1]);


HTH


The smaller the mind the greater the conceit.
Aesop
GeneralRe: Accessing properties as an array Pin
Jonathan de Halleux17-Feb-04 1:15
Jonathan de Halleux17-Feb-04 1:15 
GeneralRe: Accessing properties as an array Pin
OmegaSupreme17-Feb-04 1:46
OmegaSupreme17-Feb-04 1:46 
GeneralRe: Accessing properties as an array Pin
Omega50117-Feb-04 9:34
Omega50117-Feb-04 9:34 
GeneralRe: Accessing properties as an array Pin
OmegaSupreme17-Feb-04 12:43
OmegaSupreme17-Feb-04 12:43 
Generalapplication uses all the memory Pin
amadeonMk16-Feb-04 21:23
amadeonMk16-Feb-04 21:23 
GeneralRe: application uses all the memory Pin
Heath Stewart17-Feb-04 5:20
protectorHeath Stewart17-Feb-04 5:20 
GeneralRe: application uses all the memory Pin
Chen Pang17-Feb-04 23:13
Chen Pang17-Feb-04 23:13 
GeneralRe: application uses all the memory Pin
Heath Stewart18-Feb-04 3:55
protectorHeath Stewart18-Feb-04 3:55 
Generalclosing the main form after loading another form Pin
killermoses16-Feb-04 19:31
killermoses16-Feb-04 19:31 
GeneralRe: closing the main form after loading another form Pin
John Kuhn16-Feb-04 19:38
John Kuhn16-Feb-04 19:38 
GeneralRe: closing the main form after loading another form Pin
obelisk2916-Feb-04 19:48
obelisk2916-Feb-04 19:48 
GeneralRe: closing the main form after loading another form Pin
killermoses17-Feb-04 2:02
killermoses17-Feb-04 2:02 
GeneralRe: closing the main form after loading another form Pin
Heath Stewart17-Feb-04 5:26
protectorHeath Stewart17-Feb-04 5:26 
GeneralRe: closing the main form after loading another form Pin
Charlie Williams17-Feb-04 4:19
Charlie Williams17-Feb-04 4:19 
GeneralCalling Managed C++ code in a C# App Pin
granderson16-Feb-04 12:28
granderson16-Feb-04 12:28 
GeneralRe: Calling Managed C++ code in a C# App Pin
obelisk2916-Feb-04 19:41
obelisk2916-Feb-04 19:41 
GeneralMetrics 2 english 2 twips 2 whatever Pin
Tomaž Štih16-Feb-04 11:58
Tomaž Štih16-Feb-04 11:58 

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.