473,789 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About best coding Style of C#

1.
int[] intArr = new int[255];

2.
int[] intArr = new int[255];
rgnNumberArr.In itialize();

3.
int[] intArr = new int[255];
for( int i=0; i<intArr .lenght; i++)
{
intArr [i] = 0;
}

intArr allways initilized with 0 value?
or should I initialize it?

choose best code 1,2,3?

Jun 21 '06
42 1962
ne************* **@charter.net wrote:
And some feel it is even more silly to not initialize such data. From a
managers perspective you don't know who is going to maintain that code
several years down the road when a whole new set of languages is being used
and those people may not know a thing about C#. Many perspectives can be
valid. What Albert wrote many years ago is still true, "It is all relative".


Well, in this particular case there still is a way to kill both hares.
Add comments to the lines of code which can be mistreated later. And don't
hand it to people who "don't know a thing" in the first place.
Jun 25 '06 #41
"Sericinus hunter" <se*****@flash. net> wrote in message
news:9v******** *************@n ewssvr21.news.p rodigy.com...
ne************* **@charter.net wrote:
And some feel it is even more silly to not initialize such data. From a
managers perspective you don't know who is going to maintain that code
several years down the road when a whole new set of languages is being
used
and those people may not know a thing about C#. Many perspectives can be
valid. What Albert wrote many years ago is still true, "It is all
relative".
Well, in this particular case there still is a way to kill both hares.


That's a new metaphor on me. :)
Add comments to the lines of code which can be mistreated later. And don't
hand it to people who "don't know a thing" in the first place.


Actually, I've seen such comments:

class Foo { bool a; // will be false }

I'd rather just write an executable comment:

class Foo { bool a = false; }

But I'd prefer just to assume that most people are at least as smart as me,
so I'd simply write

class Foo { bool a; }
Jun 25 '06 #42
Mark Wilden wrote:
"Sericinus hunter" <se*****@flash. net> wrote in message

....
Well, in this particular case there still is a way to kill both hares.


That's a new metaphor on me. :)


Ah, that's literal translation from my native language. I know,
translating idioms is not what you should normally do, but I was lazy
to look for an English equivalent.
Add comments to the lines of code which can be mistreated later. And don't
hand it to people who "don't know a thing" in the first place.


Actually, I've seen such comments:

class Foo { bool a; // will be false }

I'd rather just write an executable comment:

class Foo { bool a = false; }

But I'd prefer just to assume that most people are at least as smart as me,
so I'd simply write

class Foo { bool a; }


Unfortunately, we are not in ideal world, and I can understand people
who have concerns about it.
Jun 25 '06 #43

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

Similar topics

5
1940
by: SungSoo, Han | last post by:
There are two coding style when python import module. (1) import sys (2) from import sys (or from import *) I prefer (1) style. Because it's easy to read, understand module in any category .. Which prefer ? Are there any difference of the 2 styles.
125
14858
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
144
6976
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this initiative. Typically I find that coding standards are written by some guy in the company who has a way of coding that he likes and then tries to force everybody else to write code the way he likes it, not for any rational reason, but simply for the...
4
2015
by: Josh Golden | last post by:
i lead a small development team (based on some of my posts that might cause some people to choke themselves, but have no fear, i am NOT the lead developer, the people on my team are great - i'm just the manager) for my company. although we attempt to use good practices for development, we have no real experience in documentation of a project _before_ it's coded. Are there any great books out there on how to document a project before we...
9
2117
by: Rhino | last post by:
I've been updating some CSS today and got one odd error from the validator at http://jigsaw.w3.org/css-validator/. Every time I had 'background: transparent;' (or background-color: transparent;) associated with a selector, it gave me this error message: Line : 30 (Level : 1) You have no background-color with your color : #navlist li a Here's the CSS fragment that it doesn't like:
1
1463
by: kiplring | last post by:
List<string> effectList = new List<string>(); effectList.Clear(); effectList = null; using (List<string> effectList = new List<string>()) { } If there are so many calls, I should save as much memory as I can.
10
1430
by: kiplring | last post by:
I made a input window derived from System.Windows.Forms.Form. What I use is just one property "inputWindow.Message". But System.Windows.Forms.Form has so many properties, functions, evnets. So I want to hide all things except the one property "inputWindow.Message".
13
1595
by: charpour | last post by:
Hello, in the program below: #include <stdio.h> int main(void) { int x = 1, y = 2, z; z = x+++y; return 0; }
12
1481
by: Matt B | last post by:
I was just wondering if there is a "best" choice from the following couple of ways of returning a value from a method: 1) private HashAlgorithm GetSpecificHashAlgorithm(string hashString){ if (hashString == "MD5") { return System.Security.Cryptography.MD5.Create(); } else { return System.Security.Cryptography.SHA512.Create(); }
0
9663
marktang
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...
0
9511
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,...
0
10404
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, 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...
0
10195
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 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...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
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...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2906
bsmnconsultancy
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...

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.