Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
HI i want to create a fix size.
Which on assingning value for eg if i create an array of size 4.
and i have only Three values to assign Then it should return the 4 index as null to me.
Posted
Comments
Prerak Patel 30-Jun-11 7:15am    
Your question is not clear

C#
string[] myValues = new string[4];


You will have a fixed-size array of four strings, and each array element is initialized to null.

If you create an array of any numeric type, the elements initialize to 0 - all other object types initialize to null.

You could have figured this out on your own with even the most rudimetary knowledge of arrays in .Net simply by writing some code and running it under the debugger
 
Share this answer
 
v3
Comments
suhailnoorpawane 30-Jun-11 7:24am    
i tried to do like that but when i assign this value of ordermail Which are varying may be 1 or 2 or 3 or 4 the Emails Size changing to those value and not giving me the null value where it has not got value.
string[] Emails = OrderMail.Split(',');
johannesnestler 30-Jun-11 8:12am    
If you do it like this string[] Emails = OrderMail.Split(','); the array will always have the size of the split results (3 results = array size of 3). Do it like this: string[] Emails = new string[4]; and then fill this array with the results from Split() in a loop. But why you want to do this? sounds wired...
I'm not sure eactly what you mean, but maybe if you create the array with 4 elements, then fill it with nulls. Then if you only assign 3 values, the ones you have not used will return null.

If this does not help, then I suggest you try to re-phrase your question. Best of Luck.
 
Share this answer
 
Comments
suhailnoorpawane 30-Jun-11 7:26am    
Its not returning the last value at all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900