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(str ing formatSpec, System.ValueTyp e[]
valueArgs);
public static string FormatValue(str ing formatSpec, System.ValueTyp e arg1)
{
return FormatValue(for matSpec,new ValueType[] { arg1 });
}
--
Eric Newton
C#/ASP Application Developer http://ensoft-software.com/ er**@cc.ensoft-software.com [remove the first "CC."] 2 1407
Hi Eric,
"Eric Newton" <er**@cc.enso ft-software.com> wrote in message
news:Ok******** ******@TK2MSFTN GP11.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(str ing formatSpec, System.ValueTyp e[] valueArgs); public static string FormatValue(str ing formatSpec, System.ValueTyp e arg1) { return FormatValue(for matSpec,new ValueType[] { arg1 }); }
Perhaps counterintuitiv ely, System.ValueTyp e is a reference type, not a
value type. Given the method signature above, boxing would still occur.
Regards,
Dan
Eric Newton <er**@cc.enso ft-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.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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 way they
are.
***** Summary & Questions *****
In a nutshell, the current .NET generics & .NET framework make it
sometimes difficult or even impossible to write truly generic code.
For example, it seems to be impossible to write a truly generic
|
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 Point();
UpdatePoint( P );
..
..
|
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 signature, it is said to be covariant. Because the method's
return type is more specific than the delegate signature's return type,
it can be implicitly converted. The method is therefore acceptable for
use as a delegate."
It then goes on to give an...
|
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 certain application to
come up (InnoSetup in this case).
InnoSetup comes up when I double-click on the file in the regular
explorer window. However, in VSS, the SourceSafe editor comes up.
How can I fix this?
| |
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 it defines the language more
completely. Great to use.
|
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 true.
--Musthafa
|
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 tells me if a variable has
changed, give me the original and current value, and whether the current
value and original value is/was null or not.
This one works fine but is recreating the same methods over and over for
each variable type.
...
|
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 -
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |