getting a string value from object
Hello I have an object which has value "B11" i.e
object data = "B11";
i have a variable called string resultCell. How do I get B11 into resultCell.
it doesn't seem to work for me in c#. I have tried things like ....
resultCell = (string)开发者_JAVA技巧data;
resultCell = Convert.ToString(data);
More information
I am using excel services to get a value in a cell. the excel services returns a object[]. Its a single element though. I want the value in a string. i.e. B11 in the object as string.
Much of the time, calling data.ToString()
will work. Without the specific type of the data
object, there isn't any way to answer the question.
Is the value stored in a property of data
?
Edit: Could you try (string)object[i]
, where i
is the index of the particular piece of data you want to retrieve? If you need every value in the array, you'll probably want to use a foreach
loop.
i think you need to just assign value as data.ToString() to cell.
hope this work for you.
精彩评论