Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with design of a C# project - C# Newbie 1

Status
Not open for further replies.

VBdevil

Programmer
Sep 19, 2002
75
IL
Hi,

I am new to C#. I have to write an application in C# that has several forms and controls on them, and I am in the structural design phase of the project.

If I had to write this project in VB I assume I would use a standard or class module at some point...

I wanted to know if C# has modules like Visual Basic does.
If not then what features does C# have in order to implement the same functionality as modules.

Also, I would appreciate some general pointers on how to design a project in C#. For example: will each form be a class? etc.

Any help would be great!
Thanks
 
No modules in C# -- it's entirely object-oriented.

Everything is a class, especially forms. That means that to create a new instance of a form, you use the new operator to create a variable that refers to the form. If you need to set values on controls on the form, use the variable and the "dot" operator to access the public methods and properties on the form.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
If you're absolutely brand new to .NET you will find it to be extremely different from VB6 or any previous procedural language. I couldn't stress enough how important it is to get formal training on the structure of a .NET program rather than trying to jump straight in and only learn a new syntax. Even VB.NET is a completely new animal.

Get a book or two or at least work through some online tutorials. (A simple Google search will find plenty).

One that came to mind is:
[purple]Jeff
It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
 
Thanks for your replies.
I am reading about C# - I have books and tutorials...

My problem in designing my project is that I have things in my project that are common to a few forms. For example, opening or closing files and saving data to these files. In VB, I would have one module that would do all of this, and then have the relevant forms use this module.
If there are no modules in C#, then how can I do this?

Also, I have a couple more questions regarding .Net:
1. what type of applications is VB.net better for and what type of applications is C# is better for?

2. can I write an application or a project in the .net framework that is written partly in C# and partly in VB.net?

thanks for all your help...
VBDevil
 
Right now, VB.NET and C# are nearly identical. All .NET languages will compile to the same IL, run on the came CLR and reference the same class library. There is some divergence coming: here is a discussion about that:
You can mix and match languages within .NET all you want since they all compile together to the same IL anyway.

I would create a "FileAccess" class in your app. A FileAccess object would contain methods for reading and writing to the actual files. I am admitedly a novice in OO myself, so I would defer any further comment on that method or a better way to the experts.

[purple]Jeff
It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
 
In VB, I would have one module that would do all of this, and then have the relevant forms use this module.
If there are no modules in C#, then how can I do this?
Put this code in a FileReaderWriter class.

1. what type of applications is VB.net better for and what type of applications is C# is better for?
Traditionally, VB has been better for rapid application development (RAD). C# has been seen as the more rigorous language, suited for writing high-performance code (although you can do it VB.net, too, we're talking appearances here).

2. can I write an application or a project in the .net framework that is written partly in C# and partly in VB.net?
Yes. You can have an assembly (like a DLL) writen in C# call into another assembly that was written in VB.NET. The requirement for this to happen is that both assemblies must have their public APIs follow the CLS specification. This is because some .net languages are case-sensitive (like C#) and others are not (like VB.NET), while some languages don't have unsigned numeric types (like VB.NET). You cannot have VB & C# code mixed in the same assembly.

If you put this in your AssemblyInfo.cs, the compiler will tell you when you violate the CLS:
Code:
// Tell the .NET runtime that we comply with the CLS specification
// This will cause the compiler to complain if we expose a type that
// doesn't follow the CLS (like a UInt32)
[assembly: CLSCompliant(true)]
Chip H.

____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top