|
Why some people move the using into the namespace. Can reduce the size of the program file?
For example,
namespace test
{
using System;
using System.Net;
public class classA
{
...
}
}
modified on Wednesday, July 7, 2010 11:28 AM
|
|
|
|
|
It is just the matter of coding guidelines on follows. IMO using statements should be outside the namespace.
yu-jian wrote: Can reduce the size of the program file?
IMO it cannot alter the file size. (I thought you meant keeping using statements inside namespace would reduce file size)
The overall file size would reduce since you will not be using fully qualified names everywhere in the code. It also makes the code more readable.
modified on Monday, April 19, 2010 1:03 PM
|
|
|
|
|
That doesn't depend on where the directive is.
d@nish wrote: It also makes the code more readable.
Not once it's pasted in a forum.
|
|
|
|
|
I am only fully of curiosity that why coder does that. So I guess whether it can reduce the file size. Now I know it not reduce the exe size, but it is a good way to make code more readable.
Thanks for your reply.
|
|
|
|
|
Hi,
such using statements do not contribute to the EXE/DLL file size.
All they do is allow for a smaller source file, as they enable shortcuts such as TextBox for System.Windows.Forms.TextBox
|
|
|
|
|
And I thought he is saying that keeping using statements inside namespace would reduce file size.
|
|
|
|
|
It will have no effect on the compiled size. The difference in source code size depends on how you indent the code within the namespace.
I'm not a fan of the using directive at all, but if you are using it to define aliases, it allows things like:
namespace MySqlClientStuff
{
using Connection = System.Data.SqlClient.SqlConnection ;
...
}
namespace MyOleDbStuff
{
using Connection = System.Data.OleDb.OleDbConnection ;
...
}
However, those may be better in separate files anyway.
There should be little need for multiple namespaces within one file, so the point is fairly meaningless.
More recently I have started putting the using directives for namespaces that contain my Extension Methods inside the namespace, but that's just me.
P.S. In a further contrarian vein...
Were someone to concatenate a bunch of C# code files into one big file, using directives outside the namespaces would cause trouble.
modified on Monday, April 19, 2010 1:23 PM
|
|
|
|
|
If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?!
Thanks....
|
|
|
|
|
|
I forgot to say al the parameters are saved in SQL server and it will be populated into hashtable, dictionary or whatever your recommendation is so that I don't need to connect to the database every timeto read a single value.
|
|
|
|
|
0) Dictionary uses a hashtable.
1) Are your settings all one datatype?
|
|
|
|
|
One thing to remind, if you try to save settings in either of the data structures as a xml file then you are out of luck, by default both of them are not serializable. You have to implement the IXmlSerializable interface in a custom object and wrap it around the hash table.
|
|
|
|
|
|
not all one type but in worst case I can save all as string and convert within the application
|
|
|
|
|
If you want to save user settings, you can use Settings or create custom tags in the configuration file. Then you can read them from the configuration file when the application is loaded.
|
|
|
|
|
do you have an example of doing this (hashtable or dictionary) in a public class and use it across the application?
|
|
|
|
|
|
I want example of solution N-tier with code C#
can I help my ?
thanks
|
|
|
|
|
Please read the FAQs, we are not here to do your work for you. If you have a specific problem, please ask, but from what you have given it's not even certain you know what an n-teired solution actually is.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
|
|
Great site, just noted it for future use
I have no smart signature yet...
|
|
|
|
|
I smelt it +5
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Dont the same Question in Different Forums
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi All
Can anyone suggest how can we find the checkboxes inside checkedlistbox.
Iam not speaking about the checked item inside the checkedlistbox instead i need to find each and every checkbox controls included in the checkedlistbox
Thanks in advance
Santhosh
|
|
|
|