|
You should start with the C# Language Specifications at http://msdn.microsoft.com/library/en-us/cscon/html/vcoriCStartPage.asp[^]. Also understand that C# is just another language that targets the Common Language Runtime (CLR), the runtime part of the .NET Framework. All .NET compilers compile to similar IL. The only differences in the generated IL usually have to do with compiler optimizations, but some languages support features of the .NET Framework that others don't. For example, C# supports unsafe contexts (in order to use pointers for, say, quick string parsing) while VB.NET does not (yet). But this is not really a feature of C# per se, but a feature of the .NET Framework that C# supports.
Also understand that assemblies written in any source languages can be used by any other managed language.
Finally, there is also Managed C++ that can compile down to IL in an assembly. The major thing to realize here is that you can use mixed mode or pure managed code. Mixed mode includes native implementations that aren't managed by the CLR while pure managed code is.
It's call "managed" because the CLR managed the memory (though classes that encapsulate native resources like Windows should implement IDisposable and clean-up the native resources since they aren't managed by the CLR).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
Thanks for your reply.
I know that there is MC++ that can access to CLR, but I wanna learn C#. C# seems to be more convinent to access .NET features. I have to write an application that targets Excel 2003 in C#. I don't want to program Excel 2003 with C++, it would be too complex, while Excel 2003 is designed to be easily accessed via C# or VB .NET...
While learning C# which I discover since last monday, I need to get the equivalents between C++ and C# to go faster in my learning, for this, I translate some simple MFC applications in C#...
C# in itself is easy (it's very similar to C++), but it's the .NET framework that is not easy for a beginner in .NET. I have the same feelings with .NET that I had with MFC 10 years ago: " wow!"
best regards.
bouli.
|
|
|
|
|
I only mentioned that about MC++ to help you better understand the .NET Framework. I read that you wanted to learn C#.
You should also scan through the .NET Base Class Library reference in your help files (or on MSDN Online). Knowing what's there is good so that you can think of better solutions using what's provided. Also look through them any articles here on CodeProject for examples of programming with C#. There's also several examples in the .NET Framework SDK.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
This site, some books and MSDN library are my starting point...
|
|
|
|
|
Colin Angus Mackay wrote:
No, its not possible to separate the declaration from the implementation. There is no need for that to happen as you don't need to #include headers anywhere. IMO that is one of the better features of C# over C++.
This is not inherently correct. While it maybe in the context of C++ (i.e.; no header files in C#), you can have a separate file that is part of the same namespace which simply defines interfaces. These interfaces can then be implemented throughout your application as a whole. This could be seen as a separation of declaration and implementation.
- Nick Parker My Blog
|
|
|
|
|
Nick Parker wrote:
This is not inherently correct. While it maybe in the context of C++ (i.e.; no header files in C#), you can have a separate file that is part of the same namespace which simply defines interfaces. These interfaces can then be implemented throughout your application as a whole. This could be seen as a separation of declaration and implementation.
That's Wright.
Thank You
Bo Hunter
|
|
|
|
|
Has anybody attempted the following? If not, once I've done it, I'll submit the article!
I want to set up a class that holds a collection of arrays and lets you set up calculations on the arrays that are then run as a block. The calling code would then look something like:
ArrayContainer ac = new ArrayContainer(0, 250);
ContainedArray array1 = ac.NewArray();
ContainedArray array2 = ac.NewArray();
ContainedArray array3 = ac.NewArray();
ac.DefineCalculations();
array1.CurrentRow = array2.CurrentRow + array3.LastRow;
array2.CurrentRow = array2.LastRow - 3;
array3.CurrentRow = array1.LastRow * 2;
ac.DoCalculations();
The last line makes it go through all 251 rows of the three arrays iteratively carrying out the calculations.
Many thanks
Bernard
|
|
|
|
|
There's one major problem:
array1.CurrentRow = array2.CurrentRow + array3.LastRow;
array2.CurrentRow = array2.LastRow - 3;
array3.CurrentRow = array1.LastRow * 2; This will be executed as-is by the CLR because the expressions are compiled to IL as you see them. Instead, you should consider storing an expression string as you could with a ColumnHeader (for a DataGrid ). You would have to devise somewhere to parse this expression, thoug, perhaps using a string tokenizer like we've done in our app I architected at work. There is an article that includes source that was the basis for our string tokenizer: http://www.c-sharpcorner.com/Code/2003/June/JavaLikeStringTokenizer.asp[^]. This may help.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for this - I'll have a look at the article. I broadly had in mind that by overloading the operators, I could have them 'stack up' the commands in a buffer (I had Forth and Reverse Polish Notation in mind). The execute method would then run through the buffer, Emit it (perhaps), and then execute it repeatedly.
|
|
|
|
|
I think this wouldn't be too hard.
class ArrayContainer : CollectionBase (.. blah blah..)
And then just define operators on the ContainedArray class, but with one catch! Just store the actions (iow create a stack), and only invoke it on the DOCalc().
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi guys,
I have 2 newbies questions in C#:
- what is the equivalent of WM_NCHITTEST message in C#? I want to detect the movments of a window (Form) when the user moves it with the mouse. I tried the MouseUp and MouseDown events, but it works only in the client area of the form (like for C++)
- how to include a manifest resource in C# to apply the current theme in each forms of the application?
Thanks
Best regards.
bouli.
|
|
|
|
|
First question:
<br />
private int WM_NCHITTEST = 132;<br />
<br />
protected override void WndProc(ref Message m)<br />
{<br />
if(m.Msg == WM_NCHITTEST)<br />
Debug.WriteLine("WM_NCHITTEST");<br />
else<br />
base.WndProc(ref m);<br />
}<br />
Second question: No clue!
|
|
|
|
|
Second question: see my article at http://www.codeproject.com/csharp/dotnetvisualstyles.asp[^]. This works for application targeting the .NET 1.0 Framework on up, though .NET 1.1 added an Application.EnableVisualStyles method that you can call before executing Application.Run in your application's entry point. Note that many people have experienced odd problems with the latter method, though, while the method described in my article works because it's exactly what win32 applications do (also note that the .manifest file can stand alone from app as I mentioned, but then you have to worry about deploying that, too).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
Ok, thanks for your link. The EnableVisualStyles is simple
It's even more simple than in C++
|
|
|
|
|
How do you do that? Let's say you have the following code:
<br />
InternetExplorer ie = new InternetExplorer();<br />
IHTMLDocument2 doc = (IHTMLDocument2) ie.Document;
//NOTE: How do I know when or not the method returns a "new" object vs. using the new keyword? eg. WebRequest wr = WebRequest.Create("...") not = new WebRequest (but I only know that because it's in the documentation) ??
Back to InternetExplorer: the problem arises when I try to access any of it's interfaces. Example:
<br />
Object oNull = 0;<br />
Object oNullString = "";<br />
InternetExplorer ie = new InternetExplorer();<br />
ie.Navigate("http://www.google.com/", ref oNull, ref oNullString, ref oNullString, ref oNullString);<br />
System.Threading.Thread.Sleep(5000);<br />
IHTMLElementCollection ec = null;<br />
ec = (ie.Document as IHTMLDocument2).all;<br />
<br />
All the above works perfectly. Now:
ec.item(I don't even know how to use the params properly) or ec.tags("BODY") for example all give me one error: Referenced object does not exist in memory, or something of that sort that means you can't access it.
Help! Good book? Good article?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
First, an empty string ("") is not the same as null . For the null parameters, you should actually do something like this:
object missing = System.Reflection.Missing.Value;
object url = "http://www.google.com";
ie.Navigate2(ref url, ref missing, ref missing, ref missing, ref missing); As you can see above, too, I use Navigate2 . This is recommended by the IE Programming documentation.
As far as casting vs. new , you want to use casting. When you cast to an interface that is delcared as a RCW interface, this results in a QueryInterface of the object as you would do in C++ regarding COM. If null is returned, the object does not implement the interface.
There are several good articles about using the WebBrowser control. See the following search results for a few (especially the top ones): http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=WebBrowser[^].
Also, use the WebBrowser control by interop'ing shdocvw.dll to embed "Internet Explorer" in your application. Use the InternetExplorer object if you want to control a remote application instance through out-of-process automation.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Dear, Sir
How to display copyright sign (c in small circle,©) in Label control?
Thank You.
|
|
|
|
|
Well, you can copy it from somewhere, or hold down the alt key and type 0 1 6 9 on your keypad.
|
|
|
|
|
Sune Trudslev wrote:
you can copy it from somewhere
The trusted way I hate trying out ALT keycode combinations!
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Since strings in .NET are stored in Unicode, you can also use "\u00a9".
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
Since strings in .NET are stored in Unicode, you can also use "\u00a9".
Where can I find the resources for using the
'\u00a9' notation.
I have seen them used alot but have never
seen info on what codes mean what.
Thank You
Bo Hunter
|
|
|
|
|
It's just how you escape Unicode characters in a string. To see what the Unicode characters are, you can use the Character Map in the Start->Programs->Accessories->System Tools program group, or go to http://www.unicode.com[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Man all this time I have spent
looking for character codes.
Learn something every day.
Thank You
Bo Hunter
|
|
|
|
|
Hi,
Is there a limit to the number of rows (amount of data) a datagrid can display in a datagrid?
Is there any internal optimization in the datagrid which fetches data from the dataset only for those rows which are visible to the user? ( I saw someone say so in a NG)
Is there a limit similarly for datasets? ( I have read now and again it's only limited by the client's systems' memory...but wanted to make sure )
I am concerned since i need to display ALL the data (around 10K records).
Thanks
Rakesh
|
|
|
|
|
Rakesh Rajan wrote:
Is there a limit to the number of rows (amount of data) a datagrid can display in a datagrid?
See Process.MaxWorkingSet . This gets or sets the maximum amount of memory allowed in memory for the given Process .
Rakesh Rajan wrote:
Is there any internal optimization in the datagrid which fetches data from the dataset only for those rows which are visible to the user?
Not yet, at least in the .NET base class library. In .NET 2.0 they have introduced several new control classes, including a GridView[^] which supports virtual lists, which is to what you're referring.
There's nothing from stopping you now (there was a good article a LONG time ago about how to do this even in DHTML), but the burden is on you unless you want to buy a commercial solution like a couple from ComponentOne[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|