.NET

Reply
*Matt
Message 11 of 15 (64 Views)

Re: String formatting in .NET

11-22-2006 11:56 PM in reply to: *Matt
The converter does the job. Noprobs.
This was just a generic question on how to use the ToString("N4"); to fit my
needs.

Case closed

/Matt



"Kerry Brown" wrote in message
news:5405026@discussion.autodesk.com...
Matt

Look at
Autodesk.AutoCAD.DatabaseServices.Database.get_Luprec()
which returns an Int32

also, Tony refered to Autodesk.AutoCAD.Runtime.Converter class in
acdbmgd.dll
.. it's actually in acmgd.dll .. but still in the Runtime Namespace so it
will still work fine as quoted. .. no biggie.

///
kwb



"Matt" wrote in message
news:5405016@discussion.autodesk.com...
But how do I change the 4 to a 5 depending on, for example, LUPREC ?
(ok, this has again left the autocad relationship)

On way can be to create the format string in runtime and to use that string
to format the string i wanted.
But there must be a better way! Or... ?

/Matt


wrote in message news:5404875@discussion.autodesk.com...
If I read the last post correctly, the solution is simpler than you would
first expect. You can pass formatting arguments to the ToString() method of
the Double class/datatype.

Forgive the following, as I'm more used to C# than C++:

double x = 12345.67;
string s = x.ToString("N4"); //s is now "12,345.6700"

See http://msdn2.microsoft.com/en-us/library/dwhawy9k.aspx for more info.
*Matt
Message 12 of 15 (64 Views)

Re: String formatting in .NET

11-22-2006 11:58 PM in reply to: *Matt
I must say that printf sounds a lot more simple
But i maybee just old and grumpy

/Matt


"Tony Tanzillo" wrote in message
news:5405046@discussion.autodesk.com...
You can dynamically format a numeric value by
defining a class that implements the IFormatProvider
interface, havin a GetFormat() member that returns
an instance of a NumberFormatInfo object, whose
members can specify formatting aspects such as the
number of decimal places, and so forth.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Matt" wrote in message
news:5405016@discussion.autodesk.com...
But how do I change the 4 to a 5 depending on, for example, LUPREC ?
(ok, this has again left the autocad relationship)

On way can be to create the format string in runtime and to use that string
to format the string i wanted.
But there must be a better way! Or... ?

/Matt


wrote in message news:5404875@discussion.autodesk.com...
If I read the last post correctly, the solution is simpler than you would
first expect. You can pass formatting arguments to the ToString() method of
the Double class/datatype.

Forgive the following, as I'm more used to C# than C++:

double x = 12345.67;
string s = x.ToString("N4"); //s is now "12,345.6700"

See http://msdn2.microsoft.com/en-us/library/dwhawy9k.aspx for more info.
Distinguished Contributor
RolandF
Posts: 172
Registered: ‎11-19-2003
Message 13 of 15 (64 Views)

Re: String formatting in .NET

11-23-2006 12:47 AM in reply to: *Matt
If i unserstand it correct maybe this will help you.

int Luprec = Application.DocumentManager.MdiActiveDocument.Database.Luprec;

...

DistFPPrompt = DistFP.ToString("F" + Luprec.ToString());

DistSPPrompt = DistSP.ToString("F" + Luprec.ToString());

Dist = Math.Abs(DistSP - DistFP);

DistPrompt = Dist.ToString("F" + Luprec.ToString());

ed.WriteMessage(String.Format("\nabgewickelte Länge = {0}, erster Punkt =
{1}, zweiter Punkt = {2}", DistPrompt, DistFPPrompt, DistSPPrompt));


--
Roland Feletic
Pauser ZT-GMBH
http://www.pauser.at

hp workstation xw4200, 3GB
quadro fx1400
AutoCAD 2007, 3DSMax 8.0 SP 2
*Tony Tanzillo
Message 14 of 15 (64 Views)

Re: String formatting in .NET

11-23-2006 02:14 PM in reply to: *Matt
printf() ?? More simple?

.NET is not simple because it utilizes an all-
inclusive approach to solving problems like
localization and so forth.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Matt" wrote in message news:5405029@discussion.autodesk.com...
I must say that printf sounds a lot more simple
But i maybee just old and grumpy

/Matt


"Tony Tanzillo" wrote in message
news:5405046@discussion.autodesk.com...
You can dynamically format a numeric value by
defining a class that implements the IFormatProvider
interface, havin a GetFormat() member that returns
an instance of a NumberFormatInfo object, whose
members can specify formatting aspects such as the
number of decimal places, and so forth.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"Matt" wrote in message
news:5405016@discussion.autodesk.com...
But how do I change the 4 to a 5 depending on, for example, LUPREC ?
(ok, this has again left the autocad relationship)

On way can be to create the format string in runtime and to use that string
to format the string i wanted.
But there must be a better way! Or... ?

/Matt


wrote in message news:5404875@discussion.autodesk.com...
If I read the last post correctly, the solution is simpler than you would
first expect. You can pass formatting arguments to the ToString() method of
the Double class/datatype.

Forgive the following, as I'm more used to C# than C++:

double x = 12345.67;
string s = x.ToString("N4"); //s is now "12,345.6700"

See http://msdn2.microsoft.com/en-us/library/dwhawy9k.aspx for more info.
Contributor
bdaly
Posts: 13
Registered: ‎03-30-2000
Message 15 of 15 (64 Views)

Re: String formatting in .NET

11-29-2006 11:24 PM in reply to: *Matt
Look at the String.Format() methods: it has the sprintf formatting strings you're looking for.

http://idunno.org/displayBlog.aspx/2004071401

Bill Daly
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.