Tuesday, May 15, 2012

How to convert string to string[] in C#?

It might happen that you receive from POST a variable name that is in fact an array. So in this case you should convert your object into string[]. How do you do that?
Well, as usually, it is simple:
string[] RoomOptions = new string[] { Request["room_options"] };
So there you are.
This was for solving asp error message saying:
Error message: Cannot convert type 'string' to 'string[]'

No comments:

Post a Comment