Jump to content

Questions on C# basics, IDE, .net framework, etc (need very detailed answers)

kaddle

i learned a bit of HTML and CSS when i was younger. part of the process of learning a programming language for me is to write down the information i gather on paper in a coherent way. for example on the first paper i had basic information about what HTML is, what it does, and how it works in order starting from which information should be known first. on the other pages i listed tags and how to use them in order starting from the most basic and essential tags. same thing with CSS and its properties. so far i am having a little bit of difficulty doing this with C#. i have a guide and a video that goes over the basics but the problem is that the information isn't detailed enough, so i have some questions about the basics that i would appreciate very detailed answers to. detailed in terms of being equal parts information as well as simplicity. yes i did some googling already but the information i get is still a bit broad.

 

some of you might think that some of this information is not necessary for me to know. i'm the kind of person who needs familiarity with the language i am studying. i am also still fairly new to programming languages. i only learned the very basics of HTML and CSS and that was a long time ago.

 

Integrated Development Environment:

the IDE i was told to download to use C# with is visual studio. i downloaded the free community version. the tools/extensions i selected are the .net desktop development and the game development with unity because the reason i am learning C# is to make mobile games in unity, and eventually make bigger games. so these tools and extensions kind of give me an idea of what an IDE is, but it's not exactly explained in detail. is an IDE just a software program that is essentially a tool to help developers write and manage their code? if this is the case then can notepad++ also be considered an IDE because it has similar capabilities as well? is an IDE required for C# programming, and if so is visual studio the only IDE that works with C#? if so, why is that?

 

.NET Framework/Standard:

i read that the .net framework is a software framework mainly used on windows, but what does this mean exactly and what does it do? what is a class library? what is .net standard?

9889ui.png

 

C#:

i was told that the console app project is the most basic kind of project for C# and the guides i am learning from are based on this, so the information i will be referring to is based on that.

9889ui.png

 

using:

can i get some detailed info on all of this "using" stuff? from what i can read and tell, it's a keyword that imports a namespace. in an IDE like visual studio the keywords are automatically generated based on the project type that is selected to import the necessary namespaces. perhaps my confusion on this is mainly because HTML and CSS didn't have anything like this. what does "using system" mean exactly? what purpose do they serve?

 

namespace:

i read that namespaces are essentially a collection of classes. does this mean that namespaces are the most fundamental containers in C#? if namespaces are just supposed to be containers then why do the namespaces imported by using seem to serve a different function than the namespace where my code is supposed to go?

 

i can see at the top that there are tabs for the different sections of code within the consoleapp5 namespace but there aren't any tabs for the namespaces imported by the using keywords. does this mean that the namespaces imported by the using keywords are a different type of namespace than the one generated for my code or is it because visual studio determined that the tabs are only necessary for the part of the project i will be working with?

also, does this mean that the project is broken up into different sections based on namespaces even though it is all written in the same file? if so then does this means that each namespace is essentially its own file (assuming the "using" namespaces are different).

 

does there only need to be one namespace for my code? why or why not?

 

curly brackets:

i read that the curly brackets are essentially signifying the beginning and ending of a section within the file/program. does this mean the code in each namespace i code in does not affect all other namespaces? is this mainly a method of separating each class container and the code within each class from all of the other classes within the namespace?

 

class:

so apparently a class is a container where the main code for the program is written which will be executed when the program runs. am i correct in assuming that the C# language is essentially just a namespace container which holds the class containers and inside the class containers is where the magic happens? so the purpose of the namespace and class containers is to provide order to the file and keep track of the real code?

 

if so, is this how it is for all C# project types or is it just for the console app project?

Link to comment
Share on other sites

Link to post
Share on other sites

 

It's not really feasible to full academically understand a programming language as step 1 to being able to use that language. You really don't need to know the "very detailed" info about .NET when you're just starting out. A console app is a perfect place to start, and is all you need to start the basics. If you let yourself get bogged down by the rabbit hole that is language design, compilers, frameworks, compilation targets, etc., you are never going to get into actual programming. Start with the basics, then build on those, until eventually you will find that learning more about .NET comes naturally from solving a problem that led to that being needed info, or you might just want to learn it for its own sake but you'll have a fundamental understanding that gives context to what you're learning.

 

You're asking for "very detailed" info about things that won't really mean much to you without some familiarity. The significance of namespaces is something that's hard to convey without being familiar with how to organize multiple pieces of code together. That's probably why what you're googling isn't clicking for you.

 

Here's my attempt to explain these things as detailed as possible to someone who doesn't yet know about writing code (html/css don't count in this context):

 

 

 

IDE:

You're right that IDEs are just programs that help devs write/run/debug code. Yes notepad++ could be an IDE, but it would require some plugins in order to provide the same features many other IDEs provide out of the box (which may be fine depending on what you're after). For .NET specifically, Visual Studio provides a huge amount of features (since .NET is a microsoft thing and visual studio is made by microsoft as well), so it's not likely that you're going to be able to find enough plugins for a bare bones IDE to be able to compare to visual studio for microsoft .NET development. Which IDE you use is totally up to you, and don't worry too much about it when you are just starting since you won't have a barometer for comparison yet. Visual studio is fine for what you're doing, so keep at that for now.

 

.NET:

.NET is just a platform that is made by windows to make things easier on developers. A lot of the code involved with making certain apps is built into frameworks (this is true beyond just .NET), and .NET is just one example of a framework/platform. These frameworks provide libraries and utilities for developers to use (for example, there is a .NET library for making http requests so you don't have to worry about about managing web sockets directly). There are tons of other frameworks and platforms, but just using the one that is commonly used for the language you're working in is fine. Use .NET when writing c#, use the Java JDK/JVM when writing java, use node when working with server side Javascript. Some languages, like C, don't really have one, but that's because they are close enough to the machine code that one isn't really needed, and instead of a framework beneath C, you can avoid doing extra work by just using other C libraries. The specifics of compilation don't matter as much for C#, since it's a JIT compiled language (aka the framework does that stuff for you).

 

using:
using is just a shortcut to make your code a bit cleaner. If you are using System.Net, you could just make WebRequest object, instead of having to type out System.Net.WebRequest. The only major thing to watch out for is if 2 namespaces have the same name for something. Then you'd have to be more specific by typing it out so that the system knows which one you are referring to.

 

1 hour ago, kaddle said:

curly brackets:

i read that the curly brackets are essentially signifying the beginning and ending of a section within the file/program. does this mean the code in each namespace i code in does not affect all other namespaces? is this mainly a method of separating each class container and the code within each class from all of the other classes within the namespace?

Think of curly brackets as simple containers

namespace ExampleNamespace {
    // stuff in here is in the namespace ExampleNamespace 
}



class ExampleClass {
    // code in here is in the class ExampleClass.
}

You'll get the hang of this kind of syntax stuff by just following the basic tutorials and building on it.

 

1 hour ago, kaddle said:

so the purpose of the namespace and class containers is to provide order to the file and keep track of the real code?

Yes, but also a lot more. How to properly use classes is more about abstractions and making designs that are understandable. This is called Object Oriented Programming, and is not something that's easily explained without more of a basic code knowledge. But yes, tl;dr classes are just ways of laying out code. You could technically write out any application with only a single class (and all in one big main function), but that would be horrible. Lots of lower level languages don't even have classes, but do have other ways of organization. They are not needed for code to function, they are there for organization.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, kaddle said:

can notepad++ also be considered an IDE because it has similar capabilities as well?

There is no clear, absolute definition of an IDE. Basically, an IDE is "a text editor with a compiler built-in", and one could argue whether a text editor with external tools can still be called an integrated environment. The borders have become less clear though as "editors" like Atom, Sublime Text and Visual Studio emerge which actually are language-agnostic IDEs.

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

I'll answer too as different answers might be easier to grasp than other because of the wording speaks more to you. I'll try to keep mine as simple as possible.

 

IDE : The IDE is the editor for not only C# but many language that Visual Studio Support. You could use Microsoft Word as an example where it has 1 interface but can edit *.doc (word file), *.docx (2012 + word files), *.txt (notepad files), *.rtf (rich text files), *.html (web page). But the IDE of Visual Studio will slightly change by Adding/removing/disabling some options depending on the type of project you are working with.

 

.NET : it's only a bunch of files with an engine that has code in it that you can use to compile libraries or software using it. Works exactly the same way as Java, Python. You need to install something in order to run it. Java is Java JDK or Java SDK, Python well this one has hundreds of engine.

 

Using : First to use code you need to point to the library. By default most project will have "Reference" in the project treeview. This mean those libraries are available to you in the entire project. Using in a specific file allow you to not have to type the full namespace.Class.Method to access it. Since it can be many namespace deep you can avoid retyping over and over again the whole thing by simply adding the using. 

 

Namespace : The easiest analogy is folders. a namespace is a folder. Whatever you put inside it's brace require either typing the "folder path" i.e. myNamespace.Class1 or adding like explain above the shortcut "using myNamespace" so you can only type "Class1". You can put namespace into another namespace without a problem. This is like a folder in a folder. The main use is to categorized large section of a program.

 

Curly braces : You are right they are beginning and closing statement. They do what they are supposed to do and that is enclose things. object created inside braces are not accessible outside the braces. Anything inside the can see it and that even if there is other braces levels. An example is by your code is you were to put something right underneath the namespace it would be visible inside the braces of the static void Main because you are still within the braces that contain the thing you added.

 

Class : a class is an type of object that in .Net has extra built in functions to do things. Whenever you need an object with many properties this "should" be the object you want to create. In all executable project type you need what's called an entry point. This entry point is what the application call to start and once the code return to the original line where it called that entry point the program stops. In console applications the project specifically launch the Static void Main method by default so once it reaches the closing brace of that method it goes back to the main entry point and close the program.

 

Now there is something very important and is true for most language but i will keep it C# specific. You could code a whole program in a single physical file. in C# they are .cs files. But that would be insanely messy. Therefore you can create many folders and files to keep things clean. If you create a class File in the folder B that is within a folder A then you will notice the class will automatically create with the namespace matching the folder names. This is NOT mandatory. You could have a file with namespace called dog in a folder called cat. The only use of namespace remember is to categorized things. Anything in the same namespace see each other. The use of folders and files are to keep things clean (and sane).

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Franck said:

The easiest analogy is folders. a namespace is a folder.

Actually, those are packages.

Write in C.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, Dat Guy said:

Actually, those are packages.

a non programmer probably doesn't know what package is either.

Personally I use package all the time but pure .Net devs don't know that wording so i always have to repeat what i am asking using namespace wording instead.

Package is a the equivalent of namespace in Java and PHP AFAIK so it's not an analogy.

Link to comment
Share on other sites

Link to post
Share on other sites

27 minutes ago, Franck said:

a non programmer probably doesn't know what package is either.

Personally I use package all the time but pure .Net devs don't know that wording so i always have to repeat what i am asking using namespace wording instead.

Package is a the equivalent of namespace in Java and PHP AFAIK so it's not an analogy.

I thought namespace gives scope to some piece of code. At least that's how it is used in c++

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, wasab said:

I thought namespace gives scope to some piece of code. At least that's how it is used in c++

Same in C#. I mentioned it in the "using" and also again in my final paragraph. You needed to read the full thing to see it. It wasn't part of the quote.

Link to comment
Share on other sites

Link to post
Share on other sites

thanks a lot for the info guys. you have provided much needed clarity to the subject.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×