Home ASP.NET.NET interview questions: - Method of parsing values from string.
.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




Write a Comment
All fields marked with * are mandatory
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
By : Shiv Prasad Koirala | Aug 4th, 2011 | ASP.NET
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
By : Shiv Prasad Koirala | Nov 16th, 2011 | WCF
.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
By : Shiv Prasad Koirala | Jan 17th, 2012 | .Net
.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
By : Shiv Prasad Koirala | Sep 27th, 2011 | ASP.NET
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
By : Shiv Prasad Koirala | Aug 5th, 2011 | C#
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
By : Shiv Prasad Koirala | Aug 4th, 2011 | ASP.NET
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
By : Shiv Prasad Koirala | Nov 16th, 2011 | WCF
.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
By : Shiv Prasad Koirala | Jan 17th, 2012 | .Net
.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
By : Shiv Prasad Koirala | Sep 27th, 2011 | ASP.NET
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
By : Shiv Prasad Koirala | Aug 5th, 2011 | C#
Article Categories
YouTube Videos