How to Use String::Format Method
-
Hi All, I am New user for vc.net, My code is String ^str1=L"1",^str2=L"2",^str3=L"3"; String ^str=String::Format("{0}{1}{2}",str1,str2,str3); MessageBox::Show(str); But I want Increase the String length like in VC++; CString str; str.Format("%25s%15s%15s",str1,str2,str3); I want modify above code like that Plz suggest me Nagaraju
-
Hi All, I am New user for vc.net, My code is String ^str1=L"1",^str2=L"2",^str3=L"3"; String ^str=String::Format("{0}{1}{2}",str1,str2,str3); MessageBox::Show(str); But I want Increase the String length like in VC++; CString str; str.Format("%25s%15s%15s",str1,str2,str3); I want modify above code like that Plz suggest me Nagaraju
You need to look into formatting support in .NET. String.Format does not do formatting just template placement. ToString() supports formatting. Also see IFormatProvider and NumberFormatInfo etc.
String ^str=String::Format("{0}{1}{2}",**str1->ToString(IFormatProvider)**,str2,str3);
led mike
-
You need to look into formatting support in .NET. String.Format does not do formatting just template placement. ToString() supports formatting. Also see IFormatProvider and NumberFormatInfo etc.
String ^str=String::Format("{0}{1}{2}",**str1->ToString(IFormatProvider)**,str2,str3);
led mike
What! no printf style formatting support? What kind of C based language does not somehow provide printf style formatting. Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class. -- modified at 12:46 Tuesday 8th August, 2006
-
What! no printf style formatting support? What kind of C based language does not somehow provide printf style formatting. Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class. -- modified at 12:46 Tuesday 8th August, 2006
bob16972 wrote:
What kind of C based language
If you are doing mixed mode you can still use the C++ formatting libraries.
bob16972 wrote:
Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class.
Have not done any Java in the past couple of years, don't know if I ever will again.
led mike
-
bob16972 wrote:
What kind of C based language
If you are doing mixed mode you can still use the C++ formatting libraries.
bob16972 wrote:
Last I heard, even Java 1.5 or 5.0 or whatever it is added printf style formatting to their string class.
Have not done any Java in the past couple of years, don't know if I ever will again.
led mike
-
Hi All, I am New user for vc.net, My code is String ^str1=L"1",^str2=L"2",^str3=L"3"; String ^str=String::Format("{0}{1}{2}",str1,str2,str3); MessageBox::Show(str); But I want Increase the String length like in VC++; CString str; str.Format("%25s%15s%15s",str1,str2,str3); I want modify above code like that Plz suggest me Nagaraju
You can do this: String ^str = String::Format("{0,25}{1,15}{2,15}", str1, str2, str3); for with the values right-aligned and this: String ^str = String::Format("{0,-25}{1,-15}{2,-15}", str1, str2, str3); for values left-aligned. -- modified at 15:35 Tuesday 8th August, 2006
-
just a disclaimer... That wasn't meant toward you. I was gasping aloud so my apologies if that came off as somehow blaming you. When I reread it, it just doesn't sound right so again, my apologies. :)
-
You can do this: String ^str = String::Format("{0,25}{1,15}{2,15}", str1, str2, str3); for with the values right-aligned and this: String ^str = String::Format("{0,-25}{1,-15}{2,-15}", str1, str2, str3); for values left-aligned. -- modified at 15:35 Tuesday 8th August, 2006
Thank U very Much George, I wish u all the best Nagaraju