954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Reading a cell value from excel

// ws is an object variable of worksheet
// systype is a string variable

Range r = (Range)ws.Cells[2, 2];
systype = r.Value2.ToString();

how can I combine these two lines into one single line ?
Please help ....

surakesh
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

((Range)ws.Cells[2, 2]).Value2.ToString();


ToString() sometimes lead to null reference exception , try to avoid using it.

surakesh
Newbie Poster
12 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: