473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Question for framework guys: string.Format and valuetype boxing

Since String.Format has to box all value types to accomodate the params, and
just for sheer efficiency, are there possibly any plans for a FormatValue
method to minimize boxing?

public static string FormatValue(string formatSpec, System.ValueType[]
valueArgs);
public static string FormatValue(string formatSpec, System.ValueType arg1)
{
return FormatValue(formatSpec,new ValueType[] { arg1 });
}
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]

Nov 15 '05 #1
2 1390
Hi Eric,

"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:Ok**************@TK2MSFTNGP11.phx.gbl...
Since String.Format has to box all value types to accomodate the params, and just for sheer efficiency, are there possibly any plans for a FormatValue
method to minimize boxing?

public static string FormatValue(string formatSpec, System.ValueType[]
valueArgs);
public static string FormatValue(string formatSpec, System.ValueType arg1)
{
return FormatValue(formatSpec,new ValueType[] { arg1 });
}


Perhaps counterintuitively, System.ValueType is a reference type, not a
value type. Given the method signature above, boxing would still occur.

Regards,
Dan
Nov 15 '05 #2
Eric Newton <er**@cc.ensoft-software.com> wrote:
Since String.Format has to box all value types to accomodate the params, and
just for sheer efficiency, are there possibly any plans for a FormatValue
method to minimize boxing?


Using ValueType itself wouldn't help - they'd still be boxed, because
ValueType itself is a reference type. (I know, it's weird...)

If you think about it, the stack needs to know how big to be in bytes,
and it's not going to know that for any random value type - it would
need to know the exact value type in question.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shawn B. | last post by:
Greetings, Is it possible to create a custom ValueType object in C#? Or must I use managed C++ for that? Thanks, Shawn
17
by: Andreas Huber | last post by:
What follows is a discussion of my experience with .NET generics & the ..NET framework (as implemented in the Visual Studio 2005 Beta 1), which leads to questions as to why certain things are the...
16
by: Ed A | last post by:
Hi all: I'm using a struct of type Point that is being passed on to a method as a refrence type (boxing), the UpdatePoint method changes the coordinates of this point as such: Point p = new...
6
by: Aryeh Holzer | last post by:
Let me start with a quote from the C# Programmers Reference (where I learned the cool word "covariance"): "When a delegate method has a return type that is more derived than the delegate...
2
by: Frank Rizzo | last post by:
Sorry to post an off-topic issue here, but the VSS NG is absolutely dead. I have some files in VSS with the .iss extention. When I right click on the .iss file in VSS and select Edit, I'd like a...
12
by: Michael S | last post by:
Why do people spend so much time writing complex generic types? for fun? to learn? for use? I think of generics like I do about operator overloading. Great to have as a language-feature, as...
6
by: Manikkoth | last post by:
Hello, Just curious to see why ValueType (which the base for all value types) is a class. I thought "class" would make a type a reference type. However, IsValueType for ValueType is returning...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
8
by: Magnus.Moraberg | last post by:
Hi, Lets say I have a class called Point and I give this class the following properties - int CoordinatesInPixels{...} float CoordinatesInInches{...} And the Method -
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.