Switching to C#

L

Luc The Perverse

Short version:

Trying to learn C# - 5 years C++, 2 years Java experience :) Help!

Long version:

I find "Learning C# 2005" by Jesse Liberty to be 'slow', to say the least.
I am skimming through the book, started 2 days ago will probably finish
today.

I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

In Java it helped to be referenced to documentation on classes I needed to
familiarize myself with.

(Forgive me, I'm not sure the semantics of what I am trying to ask.) What
would be great would be a list of most commonly used .NET components?
(classes/functions?) in descending order - then I could start at the
beginning and just work on familiarizing myself in my own way. (If I don't
see how or why something is used then I can search for an example on
google.)

Any advice? I feel like I could progress quickly if I just had the right
learning tools. If the best tool for me is a book, I am not opposed to
that - but I'm positive it is not the book that I have.
 
G

gregarican

Short version:

Trying to learn C# - 5 years C++, 2 years Java experience :) Help!

Long version:

I find "Learning C# 2005" by Jesse Liberty to be 'slow', to say the least.
I am skimming through the book, started 2 days ago will probably finish
today.

I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

In Java it helped to be referenced to documentation on classes I needed to
familiarize myself with.

(Forgive me, I'm not sure the semantics of what I am trying to ask.) What
would be great would be a list of most commonly used .NET components?
(classes/functions?) in descending order - then I could start at the
beginning and just work on familiarizing myself in my own way. (If I don't
see how or why something is used then I can search for an example on
google.)

Any advice? I feel like I could progress quickly if I just had the right
learning tools. If the best tool for me is a book, I am not opposed to
that - but I'm positive it is not the book that I have.

Being somewhat new to C# I tried the Learning C# book as well. Didn't
grab my attention or pull me into what I needed to learn. That's for
sure. For me I had success using the Sams Teach Yourself Visual C# in
24 Hours book, as well as the Microsoft Visual C# Step by Step book.
These were good introductory texts, and provided enough tangible
details to give me a good foundation for what I needed to know to
start my own projects. Overall I would recommend the Sams book for
most programming languages...
 
A

Andy

I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

You'll want to check out System.Xml.XmlDocument and related classes
(the documentation will help you there), System.Web or System.Net.IO
for your uploading (depending on if you're using HTTP to upload or
another protocol) and System.Security.Cryptography namespace.

I'm not sure about where to go for right click shell integration...
but you'll probably do that on installation, and probably via the
registry (Microsoft.Win23.Registry).

Also, be sure to read up on the IDisposable interface; you'll need to
be on the lookout for that, as most classes that implement the
interface use unmanaged resources, which are only freed by calling
Dispose. The using keyword can help make sure you properly dispose of
classes which implement the interface.

Also, C# behaves more like Java than C#, so when you're designing your
program, follow the Java mindset more than the C/C++ one..

HTH
Andy
 
B

Bruce Wood

Short version:

Trying to learn C# - 5 years C++, 2 years Java experience :) Help!

Long version:

I find "Learning C# 2005" by Jesse Liberty to be 'slow', to say the least.
I am skimming through the book, started 2 days ago will probably finish
today.

I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

In Java it helped to be referenced to documentation on classes I needed to
familiarize myself with.

(Forgive me, I'm not sure the semantics of what I am trying to ask.) What
would be great would be a list of most commonly used .NET components?
(classes/functions?) in descending order - then I could start at the
beginning and just work on familiarizing myself in my own way. (If I don't
see how or why something is used then I can search for an example on
google.)

Any advice? I feel like I could progress quickly if I just had the right
learning tools. If the best tool for me is a book, I am not opposed to
that - but I'm positive it is not the book that I have.

I Googled the words "C# for C++ programmers" and found a bunch of
different links and book citations.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Luc said:
I find "Learning C# 2005" by Jesse Liberty to be 'slow', to say the least.

Professional C# from Wrox.
I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

And VS 2003 uses .NET 1.1 which is really what you need to know.
In Java it helped to be referenced to documentation on classes I needed to
familiarize myself with.

So do the same for .NET - the SDK comes with complete documentation
of all classes.

You can also read it over the internet if you so prefer.
(Forgive me, I'm not sure the semantics of what I am trying to ask.) What
would be great would be a list of most commonly used .NET components?

java.lang = System
java.io = System.IO
java.util = System.Collections
java.sql = System.Data
(classes/functions?) in descending order - then I could start at the
beginning and just work on familiarizing myself in my own way. (If I don't
see how or why something is used then I can search for an example on
google.)

Start with the docs.

Web version is here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp
Any advice? I feel like I could progress quickly if I just had the right
learning tools. If the best tool for me is a book, I am not opposed to
that - but I'm positive it is not the book that I have.

Specifically about XML look for the XmlDocument class in System.Xml
namespace.

A quick example that illustrates some concepts:

using System;
using System.Xml;

class MainClass
{
public static void Main(string[] args)
{
string[] files = { @"C:\fil1.xml", @"C:\fil2.xml" };
XmlDocument newdoc = new XmlDocument();
XmlElement root = newdoc.CreateElement("root");
newdoc.AppendChild(root);
XmlElement menu = newdoc.CreateElement("menu");
root.AppendChild(menu);
for(int i = 0; i < files.Length; i++)
{
XmlDocument olddoc = new XmlDocument();
olddoc.Load(files);
XmlNodeList elements = olddoc.GetElementsByTagName("menuitem");
foreach(XmlNode element in elements)
{
XmlElement menuitem = newdoc.CreateElement("menuitem");
menuitem.SetAttribute("id",
((XmlElement)element).GetAttribute("id"));
menu.AppendChild(menuitem);
}
}
newdoc.Save(@"C:\allfiles.xml");
}
}

Arne
 
B

Barry Kelly

Luc said:
I've been commissioned to build a C# application by a friend, involving
parsing XML, right click shell integration, uploading to remote servers,
possibly encryption. He has Visual Studio 2003 - so I guess that is what I
am using too :)

I wouldn't try to do in-process right-click shell integration in .NET if
I were you. Only one version and instance of the .NET runtime can be
loaded into a process, and the shell is a single process. That means
that if your addin (running on 1.1 since it's VS 2003) gets in ahead of
any other addins which happen to be written in .NET, and any of the
other addins are written in 2.0, they'll break.

I'd advise you to write a stub in a native language for the shell
integration, that fires up your application out of process, when needed.

-- Barry
 
J

jliberty

Trying to learn C# - 5 years C++, 2 years Java experience :) Help!
I find "Learning C# 2005" by Jesse Liberty to be 'slow', to say the least.
I am skimming through the book, started 2 days ago will probably finish
today.

Forgive me but Learning C# was never intended for you; it was intended
for novice programmers. The book that was targeted at you, with your
experience, is Programming C#. You can read about it, and read a
sample chapter (and find supporting documentation and a link to a
private, free support forum) on my web site: www.libertyAssociates.com.
I'm sure there are many other excellent alternative books as well, but
I'm not at all surprised that you find Learning C# "slow," -- given
your experience I would hope that you would. I don't think you'll
find Programming C# slow at all.

By the way, building an application in VS 2003 at this point is a very
questionable decision; it is at least a generation old, and deprives
you of many important features in C# 2. 0 and .NET 2. I'd strongly
advise taking a look at moving to VS 2005; if cost is the issue I'd
far rather see you develop with C# Express (free) than with VS 2003.

Best of luck.

-jesse.
 
C

Cor Ligthert [MVP]

Also, be sure to read up on the IDisposable interface; you'll need to
be on the lookout for that, as most classes that implement the
interface use unmanaged resources, which are only freed by calling
Dispose. The using keyword can help make sure you properly dispose of
classes which implement the interface.
Absolutely complete 100% in the wrong direction. System.Data (AdoNet)
implements AFAIK not one unmanaged resource however all classes implements
IDisposable and therefore everything is finalized by the managed code.

Cor
 
L

Luc The Perverse

Bruce Wood said:
I Googled the words "C# for C++ programmers" and found a bunch of
different links and book citations.

A similar search yielded this which I found generally helpful.

http://msdn2.microsoft.com/en-us/vstudio/aa700844.aspx

It is my niave humble opinion that C# truly is based on Java . . with C++
influence. (As opposed to the other way around.) With the semantics of
the language so similar, it would seem that with the exception of a few
minor nuances my goal should be to learn .NET framework - C# will follow :)
So has anything changed? Not really! LOL!!
 
L

Luc The Perverse

Arne Vajhøj said:
So do the same for .NET - the SDK comes with complete documentation
of all classes.

You can also read it over the internet if you so prefer.

Aren't there tens of thousands of pages of documentation? It seems a
little overwhelming!
java.lang = System
java.io = System.IO
java.util = System.Collections
java.sql = System.Data

That's easy enough :)

Book marked thank you
Specifically about XML look for the XmlDocument class in System.Xml
namespace.

A quick example that illustrates some concepts:

using System;
using System.Xml;

class MainClass
{
public static void Main(string[] args)
{
string[] files = { @"C:\fil1.xml", @"C:\fil2.xml" };
XmlDocument newdoc = new XmlDocument();
XmlElement root = newdoc.CreateElement("root");
newdoc.AppendChild(root);
XmlElement menu = newdoc.CreateElement("menu");
root.AppendChild(menu);
for(int i = 0; i < files.Length; i++)
{
XmlDocument olddoc = new XmlDocument();
olddoc.Load(files);
XmlNodeList elements =
olddoc.GetElementsByTagName("menuitem");
foreach(XmlNode element in elements)
{
XmlElement menuitem = newdoc.CreateElement("menuitem");
menuitem.SetAttribute("id",
((XmlElement)element).GetAttribute("id"));
menu.AppendChild(menuitem);
}
}
newdoc.Save(@"C:\allfiles.xml");
}
}

Arne



I see I have a lot of work to do :) Thank you for the example
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cor said:
Absolutely complete 100% in the wrong direction. System.Data (AdoNet)
implements AFAIK not one unmanaged resource however all classes implements
IDisposable and therefore everything is finalized by the managed code.

Cor

Nonsense. A database connection is definitely an unmanaged resource.
 
L

Luc The Perverse

Forgive me but Learning C# was never intended for you; it was intended
for novice programmers. The book that was targeted at you, with your
experience, is Programming C#. You can read about it, and read a
sample chapter (and find supporting documentation and a link to a
private, free support forum) on my web site: www.libertyAssociates.com.
I'm sure there are many other excellent alternative books as well, but
I'm not at all surprised that you find Learning C# "slow," -- given
your experience I would hope that you would. I don't think you'll
find Programming C# slow at all.

Wow! I did not expect to receive a message from the author of the book I
was commenting on :) BTW - I like your writing style.
By the way, building an application in VS 2003 at this point is a very
questionable decision;
*snip*

I don't doubt that. However, at the current point in time, without too many
details, this contract bid was a bit of a charity project. If he makes a
profit, or even breaks even. (IE if his customers are willing to buy the
application) I will be in a bit more of a position to negotiate.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Luc said:
A similar search yielded this which I found generally helpful.

http://msdn2.microsoft.com/en-us/vstudio/aa700844.aspx

It is my niave humble opinion that C# truly is based on Java . . with C++
influence. (As opposed to the other way around.)

You are of course in title to your opinion. However, it's not really
shared by for example Anders Hejlsberg, chief architect of C#:

"One of the key differences between C# and these other languages,
particularly Java, is that we tried to stay much closer to C++ in our
design."

http://www.windowsdevcenter.com/pub/a/oreilly/windows/news/hejlsberg_0800.html

From a programmers view you might find the similarities with Java more
obvious, unless of course you use things like enums and operator
overloading. Still, it might be valuable to know a bit about the
intentions of the people who created the language.

:)
With the semantics of
the language so similar, it would seem that with the exception of a few
minor nuances my goal should be to learn .NET framework - C# will follow :)

True. There are some things in the language itself that is good to know
about, but most of the learning is getting familiar with the framework.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Luc said:
Aren't there tens of thousands of pages of documentation? It seems a
little overwhelming!

Yes, but you are not supposed to read it all. The framework is quite
extensive, so you can't learn it all. You can use the documentation to
look up the classes that you currently need to use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

JSON.Net 6
Wonderful opinionated book on C# 16
C# analog's of Java classes 9
Why C#? 22
C# 2.0 Book 4
Is it bad to start off learning Visual C#? 10
Getting Started With C#, Part 2 17
C# usage 7

Top