.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

comma seperated for thousand value

Posted By: dotnetbubbles     Posted Date: January 27, 2011    Points:2   Category :C#
I have written the following code, when i enter this value: 258500000
it is giving correctly like "258,500,000". but if i enter 2585000000 then it is showing same value (2585000000)

my code:
string returnVal = string.Empty;
returnVal = txtNumber.Text == string.Empty ? "-" : txtNumber.Text;
int amount = 0;
if (int.TryParse(returnVal, out amount))
{
returnVal = amount >= 1000 ? String.Format("{0:#,##0}", amount) : amount.ToString();
}

pl let me know where i have to modify my code.

Thanks in advance


Responses
Author: dotnetbubbles             
Posted Date: January 27, 2011     Points: 5   

string returnVal = string.Empty;
returnVal = txtNumber.Text == string.Empty ? "-" : txtNumber.Text;
int64 amount = 0;
if (int64.TryParse(returnVal, out amount))
{
returnVal = amount >= 1000 ? String.Format("{0:#,##0}", amount) : amount.ToString();
}

Author: dotnetbubbles             
Posted Date: January 27, 2011     Points: 5   

string returnVal = string.Empty;
returnVal = txtNumber.Text == string.Empty ? "-" : txtNumber.Text;
int64 amount = 0;
if (int64.TryParse(returnVal, out amount))
{
returnVal = amount >= 1000 ? String.Format("{0:#,##0}", amount) : amount.ToString();
}



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