.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Split a String in C#.Net

Posted By: Narayanan     Posted Date: July 12, 2012    Points:5   Category :C#
Hi friends,
How to split a Empty string in C#.net?
This is my program.

string str = "";

int str1 = str .Split(',').Length;


int value is 1.
why it return 1?Please explain it.

Responses
Author: Sreeraj Nair Mungath             
Posted Date: July 12, 2012     Points: 20   

In all programming languages I know a blank string is still a valid String. So doing a split using any delimiter will always return a single element where that element is the blank String.so returns 1


Author: Narayanan             
Posted Date: July 12, 2012     Points: 20   

Hi ,
Thanks

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Sreeraj Nair Mungath             
Posted Date: July 17, 2012     Points: 20   

U R Welcome

Author: Sandip Narawade             
Posted Date: July 19, 2012     Points: 20   

string str = "sandip,ajay,sunil,meera";
int str1 = str.Split(',').Length;
string[] s = str.Split(',');

str1=4;

s[0]=sandip
s[1]=ajay
s[2]=sunil
s[3]=meera





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend