.Net Interview Questions and Answers

Search:

.NET interview questions: - Method of parsing values from string.

By : Shiv Prasad Koirala | Aug 16th, 2011 | Views : 253 | Comments : 0 Bookmark and Share

.NET interview questions: - Method of parsing values from string.

This is one of the most interesting topics asked by the interviewers to check how you can handle/solve this complicated situation in much easier ways. Most of the junior developers answer this question like they will run “For loop” and will check for “, (comma)” and later pass the value to the variables, this answer is also right but the interviewers will not be fully satisfied with this answer.

So the answer for the question should be by using “Split” function.

Split: - The split function of a string class allows you to extract individual values separated by specific character.

Now, let’s do a small practical demonstration to see how exactly “Split” function help to parse the value from a string in much easier way.

Let’s create a new project on console application for that Go to > New>File>Project>Windows> Select ConsoleApplication.



Now, just add the below code snippet in the main class.

staticvoid Main(string[] args){string str = "Shiv,India,966457";// created a string variable and assigned values.string[] values = newstring[2];// created array.values = str.Split(',');// Used split function.}

Note that, as soon as you use“Split” function in your code the VS business Intellisence will display something like below diagram.



Now, just put small debug pointer on the below line.



Later, just run your application the debug pointer will stop at the line just press F10 once and the move
 mouse pointer on the values you will find result like below diagram.



In above diagram you can clearly see that now the string values are easily parsed to the array variables by using “Split” function.

View more video on different types of collections in .NET as follows: -




Get our tutorials on .NET interview questions

Regards,

Visit for author’s more blog on .NET interview questions
 

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
0 1 1 2 1
 
Article Tags : Net Interview Question , Net
 
Comments

Write a Comment

All fields marked with * are mandatory

e01b2

 

 

ASP.NET interview questions: - Can you explain Method of Sorting GridViewcontrol in ASP.NET?

Sorting allow you to sort the GridViewcontrol data in Ascending or Descending order.... Read More

WCF Interview questions:- Which binding do we need to use for WCF REST?

In this article we will show Binding used for WCF REST. For more articles and videos visit us on www.questpond.com... Read More

.NET interview questions: - Can you elaborate project life cycle?

In this article we will explain about project life cycle. For more articles and videos visit us on http://www.questpond.com/... Read More

.NET interview questions: - How will you distinguish between ForeGround and BackGround Threading?

threading is a parallel processing unit and helps you to access multiple tasks at a one moment of time.... Read More

C# interview questions: - Explain anonymous methods in .NET?

n simple words Anonymous Methods means method which are coded inline or methods without method name.... Read More

ASP.NET interview questions: - Can you explain Method of Sorting GridViewcontrol in ASP.NET?

Sorting allow you to sort the GridViewcontrol data in Ascending or Descending order.... Read More

WCF Interview questions:- Which binding do we need to use for WCF REST?

In this article we will show Binding used for WCF REST. For more articles and videos visit us on www.questpond.com... Read More

.NET interview questions: - Can you elaborate project life cycle?

In this article we will explain about project life cycle. For more articles and videos visit us on http://www.questpond.com/... Read More

.NET interview questions: - How will you distinguish between ForeGround and BackGround Threading?

threading is a parallel processing unit and helps you to access multiple tasks at a one moment of time.... Read More

C# interview questions: - Explain anonymous methods in .NET?

n simple words Anonymous Methods means method which are coded inline or methods without method name.... Read More

Article Categories