Need help in explicit convertion of char[] to string
-
Hi, Can any one tell me explicit convertion of char array to string? i have string str and char strdata[25]; now i want to assign strdata value to the string called str. I'm getting error " cannot implicitly convert type 'char[]' to 'string' " Any idea?
-
Hi, Can any one tell me explicit convertion of char array to string? i have string str and char strdata[25]; now i want to assign strdata value to the string called str. I'm getting error " cannot implicitly convert type 'char[]' to 'string' " Any idea?
there is no explicit\implicit way on converting char[] to string, and overriding will cause a-lot of problems. just use this function (you can change and it's better to change the static in it):
static private string CtoS(char[] charArr)
{
string tmp = "";
for (int i = 0; i < charArr.Length; i++)
tmp = tmp + charArr[i];
return tmp;
}NaNg
-
there is no explicit\implicit way on converting char[] to string, and overriding will cause a-lot of problems. just use this function (you can change and it's better to change the static in it):
static private string CtoS(char[] charArr)
{
string tmp = "";
for (int i = 0; i < charArr.Length; i++)
tmp = tmp + charArr[i];
return tmp;
}NaNg
Thanks.... But i dot want to concatenate bcoz the string has to be over written for every line read from the file.
-
Hi, Can any one tell me explicit convertion of char array to string? i have string str and char strdata[25]; now i want to assign strdata value to the string called str. I'm getting error " cannot implicitly convert type 'char[]' to 'string' " Any idea?