|
Christian Graus wrote:
As a C++ programmer, the old way is to wrap it in a macro, so it occurs in place. I am writing image processing code, as you will see when Chris posts the first article. Is there a way to inline code in C#, do you know ? Image processing is an area where every clock cycle counts.
Actually - as a C++ programmer, you would wrap it in an inline function.
Dale Thompson
|
|
|
|
|
Dale Thompson wrote:
Actually - as a C++ programmer, you would wrap it in an inline function.
Not if I was doing image processing. I hate macros, but the inline keyword is a suggestion which the compiler is free to ignore, so a macro is the best way of knowing for sure the code is running in place.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
I havent really tried C# much, and have been using VB.NET with no IntelliSense problems. Does it not work as well is C#? What is "Visual Assist"?
Oh, in VB.NET, if I type "system.math" it automatically changes it to "System.Math". does this happen in C#?
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
www.wholetomato.com - it has a 30 day trial, try it for yourself. It does a LOT more than just intellisense. But for intellisense, how about being able to specify the scope from which you want to see options, if you want to see public, protected or private items, if you want to see functions, or variables, or enums. In any combination.
VA does the case correction, C# does not by itself.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Thanks for the info
Christian Graus wrote:
VA does the case correction, C# does not by itself.
Thats the impression I got. I must say, it strikes me as silly that that is the case however. It means that whatever is doing the case correction is not built into the editor, but actually into the bit that each language provides to plug-in to the editor. Or at least, so it would seem.
After being used to it in VB since 16-bit VB3, it certainly takes a bit of getting used to
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
David Wengier wrote:
I must say, it strikes me as silly that that is the case however.
Well, VB is not case sensitive, SomeClass and someclass is the same thing. In both C++ and C# SomeClass and someclass is two different classes because the languages are case sensitive. Because of that I think it would be *very* dificult to make C++ and C# correct the case for you.
I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
This is a very good point, which in fact I didnt know about C#.
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Anders Molin wrote:
I mean, if you have 2 int's called IntOne and intOne, and you just typed intone, which one should the IDE select?
This is a problem I have with VA at work - our class library includes try/catch wrappers which specify a HRESULT called hResult. Every time I type hResult, it turns it all to capitals, as it does not expand the macro and see the variable name.
If VB is not case sensitive ( and how gay is THAT ? ), then the IDE isn't doing any case correction at all, it's simply ignoring it - right ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian Graus wrote:
If VB is not case sensitive
It isn't case sensitive
Christian Graus wrote:
how gay is THAT ?
And the VB programmers proclaim that it is gay that C/C++ IS case-sensitive.
Until you get used to it, there doesn't seem to be any reason for case to matter; why would you want a variable named foo and Foo ? Once you're used to it you quickly realize that (according to my style) foo is protected and Foo is public.
When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
James T. Johnson wrote:
When I coded in VB since case matter I prefixed private members with _. A practice many C/C++ people have followed as well.
Okay, I know I will get flamed for this, but why prefix private members with anything? I dont expose variables publically, but use property methods that are public, so I never have public variables. As for private methods, why would you prefix them at all?
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
oops, guess I shouldn't be replying to messages after I wake up from sleeping on a long ride home.
I should have said private variables; because in many cases in my code a private variable would have a public get or get/set property defined for it.
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
James T. Johnson wrote:
I should have said private variables; because in many cases in my code a private variable would have a public get or get/set property defined for it.
ahhh yes... I use "m" as a prefix, so I know the variable is "mine".
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|
Christian Graus wrote:
I need to get Visual Assist on here, pronto.
I think vs.net behaves bit more nicely than the vstudio for intellisense. Its able to pickup most of the classes and variables.
But I've read somewhere(dont remember where i read) that VA is not so stable for vstudio.net, I guess the beta status explains that a bit.
Cheers
Kannan
|
|
|
|
|
Can someone tell me whats the sprintf equivalent in c#.
I want to format a string, an sql statement (insert into ...) based on some values.
thanks
Kannan
|
|
|
|
|
There is nothing as evil as sprintf in C#, but a facility similar to ostringstream is StringBuilder.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
String.Format it takes the same arguments that Console.WriteLine does which allows you to specify some formatting options similar to ?printf. Here is a link to the format string specification.
HTH,
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks.
I have another question.
Whenever I use a 'String' type in c# most of the times I end up calling the member functions directly without creating any instance are they static methods(for ex. System.String.Format), which in turn return a 'string' type.
'string' is the simple type - does this encapsulate the 'String' type of the framework.
Also, I understand I dont have to do a 'new' to access the 'string' types while the 'String' requires a 'new'.
Is that true that variables of type 'string' is created in the stack and the 'String' is created in the heap.
regards
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
'string' is the simple type - does this encapsulate the 'String' type of the framework.
string is the C# name for .NET's String type, same for int/Int32, byte/Byte, char/Char, etc. In each case its just a different capitalization for the Framework name, everything else is the same
Kannan Kalyanaraman wrote:
Is that true that variables of type 'string' is created in the stack and the 'String' is created in the heap.
Nope, String is a reference type so it is created on the heap. But strings can made Interned since I can't explain it very where here is a copy 'n paste from the docs.
The common language runtime automatically maintains a table, called the "intern pool", which contains a single instance of each unique literal string constant declared in a program, as well as any unique instance of String you add programmatically.
The intern pool conserves string storage. If you assign a literal string constant to several variables, each variable is set to reference the same constant in the intern pool instead of referencing several different instances of String that have identical values.
This might be what you are thinking of instead of the stack/heap
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Thanks a lot.
I think I need to get a book first.
Cheers
Kannan
|
|
|
|
|
I've been starting an image processing library in C#/GDI+ tonight and I've hit a couple of snags. One is asked about below, I can't see how to link two different files together, a la #include. The other is more vexing.
GDI+ provides a Bitmap class, which has a LockBits method. Well and good, but it appears that in C# I must write 'unsafe' code in order to use it to access the bitmap data of the image. In fact, Eric Gunnerson, no less, has examples of this online, so I'm pretty sure if you want to use BitmapData, you need to write code that is not going to be able to run in the grand scheme of things, i.e. over the web.
Does that strike anyone else as pathetic ? It's not an esotetic pointer, but in fact a well defined chunck of memory that I need simply to access in array like fashion. Why is that so hard ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Christian Graus wrote:
It's not an esotetic pointer
Holy thank God...
- Jason
Do you have a Pulse?
SonorkID: 100.611 Jason
|
|
|
|
|
I think what you're seeing is a direct inclusion of GDI+. It would have been nice if it had an array accessor though
James
Sonork ID: 100.11138 - Hasaki
"Smile your little smile, take some tea with me awhile.
And every day we'll turn another page.
Behind our glass we'll sit and look at our ever-open book,
One brown mouse sitting in a cage."
"One Brown Mouse" from Heavy Horses, Jethro Tull 1978
|
|
|
|
|
Well, you don't have to use LockData; you can use GetPixel() and SetPixel(), which has pretty poor performance, so it's probably not a valid solution.
I've made the same comments to the GDI+ folks. Note that there's going to be more overhead with array-based access regardless of how they do it; not only do you have the array indexing, but you also have the conversion from the bitmap format to the independant format (ie Color).
|
|
|
|
|
Yes, while I imagine Get/SetPixl is not as slow as under GDI, there is at least the overhead of the function calls per pixel.
I'd be happy if they just gave me the data in an array and left it up to me to keep track of where I was, and which was blue, green, red. While I'm on that, why does GDI+ have me specify 24BitRGB, but I get back 24BitBGR ? I know BGR is windows internal format, but why not make the flag that then ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
I havent done a great deal of research into this but I have seen example code in VB.NET that goes something like:
Public Sub DoSomething(sender as Object, e as EventArgs) Handles Button1.Click, Button2.Click, MenuItem1.Click and i really like this new "Handles" clause in defining events.
What I havent seen is the same thing used in C#. I assume you can still use AddHandler and acheive the same thing, though I havent seen that either.
I guess the first question is can you do either of these, but the real question I have is, aside from syntax, personal preference, or the stigma associated with one or the other, why should I choose C# over VB.NET?
Are there things that one does that the other doesnt? Or that one does better, that the other doesnt?
Christian, I notice you have gone straight to C# as your first .NET language. Is it based on anything other than the fact you are more used to typing/seeing braces rather than "End If"?
--
David Wengier
Sonork ID: 100.14177 - Ch00k
|
|
|
|
|