|
Colin Angus Mackay wrote: String is a reference type, so no boxing and unboxing goes on
I know. The confusion arose from not reading the OP thoroughly enough, rather than not understanding boxing/unboxing (see my post above).
|
|
|
|
|
They both do the same thing. Exactly the same. The only thing is the second forgets that objData is a string, and calls ToString to get a string out of it. As it does this, the first is more efficient, but barely. It's also cleaner.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Personally, i would have made a NetworkStream from the socket, and a StreamWriter from the NetworkStream. That way i could use the writer to easily send strings etc. And the network stream to send byte arrays,
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
respected sirs ,,,
earlier i was having a confusion now it seems to be that it has ended in a big mess .....after the completion of ur discussions plz do inform me which one is correct and feasible ...
regards
sindhu tiwari
its me sid
|
|
|
|
|
I'm sure both would work equally well, but i'd go with code 1, since i don't see much point in putting the string to an object, only to get a string back out again.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
look here
this company say: "Make your customers lives easier
With SoftInstall.net your customers won't need to install the .NET Framework before using your .NET based software, they simply download and run."
who can commentate about this technology?
|
|
|
|
|
jason_mf wrote: who can commentate about this technology?
It's not a big deal. They have encapsulated .NET framework in the EXE itself. It will be extracted and installed when your program is installed, I guess.
|
|
|
|
|
The basic idea is that your assemblies are merged with the .Net system assemblies into a single EXE file and compiled to native x86 code.
Typically, a .Net application has dependencies on many of the .Net system assemblies. These types of products remove this dependency by merging the dependent code into your assembly. This is possible, because .Net can be easily decompiled and then recompiled.
This eliminates the dependency, but your code is still shipped in IL format, which only .Net understands. So a typical .Net application is shipped in IL format and automatically compiled to x86/x64/I64/etc code when run on the target machine (which has .Net installed). Without the .Net framework installed, the target machine would not know how to run an EXE in the IL format. These types of products fix this by compiling the entire application to x86/x64/I64/etc code, then shipping that code. So the final EXE is in say x86 code, which the target box would know how to run.
This latter part limits the portability of your .Net application. Typically, a .Net application can be run on x86 (and compiled to target x86), then copied to a x64 machine. It will then be compiled to target x64, thus gaining some benefit from the faster processor. If you "pre-compile" your binaries then you cannot copy the x64 EXEs to a x86 box (vice-versa works because an x64 box can run x86 binaries).
You can use ilmerge and ngen to do the same thing that these products do, but it's not really recommended. NGen is good, if you compile the .Net binaries on the target box as part of your install. This way you get all the benefit for portability and speed.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hello!
I am developing MDI application in C# which should hold different processes as its childs. Can any one help me please?
For example: I want to have MDI childs as --> notepad, command window etc....
Sr. Software Engineer
TESCO, India
|
|
|
|
|
What is your specific question?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello everybody!
I would like to know how can I publish an application with VS2005 to make it works not only for a single local user purpose.
After installation I can launch my application on local computer only from current (which has installed) user account. But I need this application to be available for any local user account.
Thanks in advance.
Igor Zenyuk
|
|
|
|
|
How to change a label text or disable a button on a Web Form application from a thread. Is it possible in managed C# as it produces error that you can not access Form components from another thread compared to managed C++ Windows Forms
chesnokov
|
|
|
|
|
You can't access controls directly from a thread. Because controls are in another thread. You need to use delegates for this. Use the InvokeRequired property to identify the threads are different. According to that make calls. Check this MSDN[^] article for more idea.
BTW, you can use ReportProgress enabled BackGroundWorker class, which provides inbuilt support for all these.
|
|
|
|
|
I have an application in that all conncetion string are in config files ..
so what i need to do to use all those values what ever in the config files...
Thanks alot..
T@SU
|
|
|
|
|
erm... look them up in the config file ? If you're looking them up all through your code, then your code is ultimately broken, as it clearly is mixing it's data layer code throughout the app.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
No what i am asking here i have config file/debug folder...
that contain some field like "connectionString"
so i have to use this connectionStringin my C# code so how can i use... i need to read this config file or anyother way to do so..
Thanks for your reply...
T@SU
|
|
|
|
|
Check out System.Configuration.
|
|
|
|
|
Microsoft's Best Practices guide says two things:
1. always validate enum values passed to a method
2. don't use IsDefined, as it forces a metadata lookup and can impact performance
They recommend using a range to validate the enum (ie, less than Days.Monday, greater than Days.Sunday, etc).
However, I'm using enums where the values aren't necessarily contiguous.
So, without using Enum.IsDefined(typeof(<passed enum="">), value), how can I test to see if the passed value is actually a valid value within an enum?
|
|
|
|
|
|
Just out of curiosity, did you read the post? Did you feel it answered my question? I did not...
This blog posting predates the book I was referring to (Practical Guidelines and Best Practices (for MS VB and Visual C# Developers, Microsoft Press, 2005). It appears to merely restate the problem - do validate the arguments, don't use IsDefined . Although, it does add some reasons why IsDefined is bad...
What is the alternative, then?
|
|
|
|
|
About all you could do is test the contiguous ranges, so suppose you had the following defined:
public enum MyEnum
{
Enum1 = 0,
Enum2 = 1,
Enum3 = 3,
Enum4 = 10,
Enum5 = 20
} You could do this as
if (myValue >= (int)MyEnum.Enum1 && myValue <= (int)MyEnum.Enum3 || myValue == (int)MyEnum.Enum4 || myValue == (int)MyEnum.Enum5)
{
} It's not pretty but it would work.
|
|
|
|
|
Heh. My enum has 68 members. Basically, I'd have to loop through them all, checking equivalency. This was a solution I already passed on once...
Why oh why didn't they implement the InvalidEnumException, I will never know (yes, I know there's one in System.ComponentModel, but you can see right in the article that MS doesn't want you using that one, either).
Sigh. Write my own.
|
|
|
|
|
I am developing a program running on mobilephone using c# 2005,when my program is running,I need to know if the mobilephone is downloading or uploading data from internet online,how to do it?
|
|
|
|
|
Not sure. But I would try to watch packets and see if they are being transmitted or received.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
how to watch if the packets are being transmitted or received?
|
|
|
|