|
The style I use, which is (or was) adopted from MS's recommended style:
Uppercase first letter of each word on method names and properties.
camelCase* local variables and method arguments.
camelCase private member-variables in a class.
If you have an abbreviation, that would normally be all capitalized and it is only 2 or 3 letters long, then only the first letter gets capitalized (to fit in with MS's naming of the Sql* and OleDb* classes). I don't always follow this one, especially when I have something like CustomerID. Putting a lowercase 'd' there just looks wrong.
No m_ or _ for private variables.
Constants/readonly variables have uppercase first letter for each word.
*camelCase means to capitalize the first letter of each word, except the first, also Java style.
Rocky Moore wrote:
Some use the "this." to prefix member variables in usage (I think just so that they can use the intellisense ).
It depends, if you have a private member variable named myVariable and you need to use that variable in a method which has a local variable or argument, myVariable . To access the private member you need to prefix the name with this. otherwise you access the argument/local variable. Typically you see this with arguments because (to me) having a local variable of the same name just seems wrong.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
James T. Johnson wrote:
The style I use, which is (or was) adopted from MS's recommended style:
Well, a lot of code from Microsoft still has underlining. Seems many still are not with the program
This is the style I have used since I started but I have ran into a little problem with this though. If you have a private variable called "customerID" and you have a property called "CustomerID", when you build a contructor and pass in a varible, it looks off to have a parameter "customerID" and be forced to use the "this." in front of the member variable. That is the only I have found where some prefix on member variables could be a good thing.
One of my other pet peeves is that C# does not allow private variables at method level. I know it is not that big of thing to have them declared at class level and some people reason that it should be declared there to make it more obvious that it exists. Personally, I think the knowledge of the variable should only be at the method level, nothing outside the method should know or have access to the variable. But I understand that "static" does not quite mean the same thing as it did in our C++ world.
James T. Johnson wrote:
I don't always follow this one, especially when I have something like CustomerID. Putting a lowercase 'd' there just looks wrong.
I agree with that. I still use "customer_ID" in mine which is the only time I use an underline.
Rocky Moore <><
|
|
|
|
|
James T. Johnson wrote:
If you have an abbreviation, that would normally be all capitalized and it is only 2 or 3 letters long,
Actually, that only applies if it's three letters long like System.Xml
If it's two letters long, both are capitalized, like System.IO so your CustomerID is fine.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
Hi!
I wanna to build a flow chart program in c#. It is like a simpler IDE. The canvas contains the block (rectangle or circle), link shape, some buttons and lists. If these buttons and lists can make use of the control in dotnet, it will save us a lot time to simulate out ourselves. In the program's design time, user can draw the block and link them, drop the control of dotnet into the block. Adjust its position, size , change its title, and maybe assign some script of vbscript or jscript to the event like button's click. In run time, all element can't be moved, only the event are responsed.
Do you think it possible in dotnet? Is there any example or link to study?
|
|
|
|
|
|
hello,
is there any example shows the pictureBox drag&drop function.
I want to let user drag the picturebox within application.
but I don't know how to do.
Could anyone show me? thanks
|
|
|
|
|
I am having trouble of loading bitmap (contains 10 images) into the imagelist.
I have embedded toolbar strip (bitmap) into the form's resx file. (using Lutz Resourcer)
Now how to access the images stored in that bitmap?
When I go to the ImageList -> properties -> Images -> Collection -> Add ...
It asks for the image file again. How to tell ImageList that the bitmap image already included with the project?
How to retrieve these images at design time?
I have seen few samples where the bitmap's property RawFormat shows "MemoryBmp".
(NewB)
|
|
|
|
|
"When I go to the ImageList -> properties -> Images -> Collection -> Add ..."
if you used ImageList by load from resx file , you no need use its properties and if you do so you also never see iamges on list. Because it embedded all of images from resx file.
To get image from Imagelist you can do like this :
protected Bitmap GetImage(int ImageIndex)
{
return (Bitmap)imgList.Images[ImageIndex];
// imgList is Imagelist that you loaded.
}
If you want to see all of Images in List you can use IconSucker to load file resx then select index image depend on you.
.....
|
|
|
|
|
Hello!
In a listbox you can easily set the height of all items by
listbox.defaultItemheight.
Is it possible to change the itemheight in listview, too?
hope, u can help me.
Hurlie
|
|
|
|
|
If I have a string that has null characters at the end, how can I remove them?
Doing Trim('\0') didn't work and I can't think of anything else to try, besides manually finding the position of the last non-null character and then removing everything after it or something like that.
|
|
|
|
|
r u using CString?
Nuno Henrique Mendes
|
|
|
|
|
ThemRight()? You mean TrimEnd()? None of the trim functions worked.
|
|
|
|
|
Trim trims spaces not anything else. If you want to trim
other chars you need to use the Trim( new char[]{' ', '\0'} );
or what ever you need. TrimEnd( new char[]{' ', '\0'} );
TrimStart( new char[]{' ', '\0'} );
|
|
|
|
|
Yees, but as I thought I said, it didn't work.
|
|
|
|
|
string str;<br />
byte [] charStr = new byte[] {(byte)'T', (byte)'e', (byte)'s', (byte)'t', 0, 0, 0, 0, 0, 0};<br />
str = Encoding.ASCII.GetString(charStr);<br />
<br />
str = str.TrimEnd(new char[]{'\0'});<br />
This code works. Make sure you are assigning the return value of TrimEnd method to your string. It does not actually trim the contents of string object but rather generates a new trimmed string.
|
|
|
|
|
After looking at docs, this is even better:
<br />
str = str.TrimEnd('\0');<br />
Also, if you are reading a null terminated string, there is a chance you have garbage characters after the terminating null. This will prevent Trim methods from working. So, your best approach would be:
<br />
int Index = str.IndexOf('\0');<br />
if (Index >= 0)<br />
str = str.Substring(0, Index);<br />
|
|
|
|
|
can someone tell me how can i get a DataSet and put it into a RecordSet?
if u know this please help me.
thanks
Nuno Henrique Mendes
|
|
|
|
|
I wrote a windows application using threads. There is some images is in my main form. Form was working well. Then i added a delegate to add controls to main form from another thread. Like this:
using System.Xml;
using System.Threading;
delegate void AddTabPage( string strUniqueID );
namespace ggg
But now, i get a runtime error like this:
An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "Form_OperatorMain.resources" was correctly embedded or linked into assembly "SupportAliveOperator".
baseName: Form_OperatorMain locationInfo: SupportAliveOperator.Form_OperatorMain resource file name: Form_OperatorMain.resources assembly: SupportAliveOperator, Version=1.0.1238.30259, Culture=neutral, PublicKeyToken=null
can anyone help me?
thanks..
|
|
|
|
|
how can i put an icon in a menu item
thanks
Nuno Henrique Mendes
|
|
|
|
|
You can't do it using standart .Net menu, but you can use this cool library[^].
(Menus with icons, floating dockable panels etc..)
i'm only pointer to myself
|
|
|
|
|
You don't need a special class or library to do it. It's not "that" hard. I just went through the pain of having to figure it out myself. I posted in two questions and though I didn't get the responses I needed, I was able to peice it together and post the answers.
See these two posts over at CodeGuru.
Images in menu
Matching Font and background color
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
How can i make a mainMenu Dockable/Floating?
thanks
Nuno Henrique Mendes
|
|
|
|
|
Ok guys.
Last time james and jonny helped me out. Thanks.
Look at the code outline and tell me how to do it. My main concern is to use a lib that uses pointers as unsafe code. I don't have a clue.. how to go about this... Give some basics about unsafe coding and pointer usage in C#.
This is the error that shows up:
::::The best overloaded method match for 'CsGL.OpenGL.OpenGL.glGenTextures(int, uint*)' has some invalid arguments
The glGenTextures prototype is as follows-
glGenTextures(int,uint*);
Code outline:
.......................................
namespace CORETextureSpace
{
public class CORETexture
{
unsafe public static void CreateTexture(ref uint[] textureArray,string strFileName,int textureID)
{
...............
OpenGL.glGenTextures(1,textureArray);
................
}
}
}
...........................................
namespace GL{
public sealed class myGL5 : Model{
..................
public const uint MAX_TEXTURES = 1;
public static uint[] g_Texture = new uint[MAX_TEXTURES];
....................
public override void Initialize(){
///////////////////////// This line
CORETexture.CreateTexture(ref g_Texture,"bitmap.bmp",0);
}
}
}
"Excellence is never an accident" - JJC
|
|
|
|
|
nosmij wrote:
OpenGL.glGenTextures(1,textureArray);
Should probably be something like:
fixed(uint* tFirstElm = textureArray)
{
OpenGL.glGenTextures(textureArray.Length, tFirstElm);
} The glGenTextures requires a pointer to a uint which it then treats as an array. So you first have to make sure the array doesn't move (a GC can cause memory to move around) via the fixed keyword. Then you can create the pointer to the first element of the array. That is then passed into glGenTextures .
HTH,
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
Anyone know how to make a ActiveX control in C# ?
(visual studio)
Thanks
|
|
|
|