Click here to Skip to main content
15,886,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wanted to assign a string into a array of string.But the compiler does let me doing it

Here's the following code

string[] sSuccessCode;

sSuccessCode = row.EMPLOYEECODE;

please give me some suggestion
Posted

You can assign a string to an array in any of the following ways:

C#
string[] sSuccessCode = new string[4];  //specify size
sSuccessCode[0] =row.EMPLOYEECODE;
 
Share this answer
 
v2
Comments
Karthik_Mahalingam 24-Dec-13 5:01am    
good answer..
smrafat 29-Dec-13 3:04am    
thanks for the solution
santhosh and Trushank answer is fine..

this is another way for your issue.

C#
string[] sSuccessCode;
        List<string> lstsSuccessCode = new List<string>();
        lstsSuccessCode.Add(row.EMPLOYEECODE);
        sSuccessCode = lstsSuccessCode.ToArray();
 
Share this answer
 
Comments
agent_kruger 29-Dec-13 5:29am    
why make it so difficult?
initialize array size:-
C#
string[] sSuccessCode = new string[4];  //specify size
sSuccessCode[0] =row.EMPLOYEECODE;
 
Share this answer
 
Comments
Karthik_Mahalingam 24-Dec-13 5:01am    
good answer
 
Share this answer
 
Comments
smrafat 29-Dec-13 3:04am    
thanks everyone for the solution

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