Showing posts with label Csharp. Show all posts
Showing posts with label Csharp. Show all posts

Sunday, July 30, 2017

Why and When Should One Start Learning C#?

This post may be interesting for those who are just thinking of starting to learn programming, but are afraid to take the first steps because of the difficult, according to some opinions, theory.
For those who are willing to master a new sphere of knowledge and apply it in work – I’ll just mention – it's never too late to start learning – let it be programming or something else! If you have the motivation, desire to learn and the chosen subject area – just start learning!
Here, I’d like to tell a couple of words in favor of C# (C Sharp) technology. In the other articles, here at my blog, you may read professional materials on C# programming.
Now, let’s figure out why one should consider learning C# programming language?
●     C# is a fairly young programming language. It appeared about 14 years ago and derived from C. So, it is a modern programming language, which gives the specialist, mastered it, an advantage on the IT market. Besides, there are a huge number of powerful libraries, tools for unit testing, and whatever else you need to create C# code.
●     Unlike C, which is a low-level programming language, C# is a high-level language and the one easy to start with (in my opinion).
●     C# is an object-oriented programming language. It gives the programmer a possibility to work on a high level of abstraction, which makes work much more effective. You don’t need to bother about memory allocations and many-many other low-level problems.
●     It is extremely popular in different areas, based on C# you can create games, desktop application, and websites.
●     C# is on 9 positions higher that Java and on 7 positions higher than C++ in a Most Loved programming languages category in Stackoverflow Developer survey.
This list of C# benefits may be continued, you are welcome to leave your vision on this topic in comments below the post.
Talking about learning C# for absolute beginners, there are many ways to do this:
1.      A professional approach is to apply to university program for Computer Sciences, where you’ll study all related subjects.
2.      Apply for a paid course, where a coach \ teacher – former or a current software developer will teach you with a group of people, and share his experience and knowledge.
3.      Start online programming course yourself. It may be a free or a paid one, you can find a bulk of them on the Internet. Here, I’d like advice free C# tutorial for absolute beginners – Codeasy.net, where you learn while reading an adventure story and fight with machines side-by-side with the characters of the story. It may be a good start for complete beginners, who are afraid of dry and complicated technical theory. Besides, this tutorial has practical tasks, so one can practice coding while reading the story. 

No matter which way you’ll choose, if you have the desire, hard working will lead you to success. Even if you want to try yourself as a programmer for self-development or as a hobby, then it's certainly never too late.

(Thanks to Julia Rybalkina @rybkayulia@gmail.com - Codeasy.)

Saturday, August 6, 2011

Single & Multimodule Assembly

A single-module assembly has a single file that can be an EXE or DLL file. This single module contains all the types and implementations for the application. The assembly manifest is embedded within this module.

A multi-module assembly consists of multiple files (zero or one EXE and zero or more DLL files, though you must have at least one EXE or DLL). The assembly manifest in this case can reside in a standalone file, or it can be embedded in one of the modules. When the assembly is referenced, the runtime loads the file containing the manifest and then loads the required modules as needed.

1. Benefiting from Multi-Module Assemblies

Multi-module assemblies have advantages for real-world programs, especially if they are developed by multiple developers or are very large.

Imagine that 25 developers are working on a single project. If they were to create a single-module assembly to build and test the application, all 25 programmers would have to check in their latest code simultaneously, and the entire mammoth application would be built. That creates a logistical nightmare.

If they each build their own modules, however, the program can be built with the latest available module from each programmer. This relieves the logistics problems; each module can be checked in when it is ready.

Perhaps more importantly, multiple modules make it easier to deploy and to maintain large programs. Imagine that each of the 25 developers builds a separate module, each in its own DLL. The person responsible for building the application would then create a 26th module with the manifest for the entire assembly. These 26 files could be deployed to the end user. The end user then need only load the 1 module with the manifest, and he can ignore the other 25. The manifest will identify which of the 25 modules has each method, and the appropriate modules will be loaded as methods are invoked. This will be transparent to the user.

As modules are updated, the programmers need only to send the updated modules (and a module with an updated manifest). Additional modules can be added and existing modules can be deleted; the end user continues to load only the one module with the manifest.

In addition, it is entirely likely that not all 25 modules will need to be loaded into the program. By breaking the program into 25 modules, the loader can load only those parts of the program that are needed. This makes it easy to shunt aside code that is only rarely needed into its own module, which might not be loaded at all in the normal course of events. Although this was the theory behind DLLs all along, .NET accomplishes this without "DLL Hell," a monumental achievement.

For more on Multimodule assembly :




Debugging & tracing in C#.NET

Debugging refers to the process of trying to track down errors in your programmes. It can also refer to handling potential errors that may occur. There are three types of errors that we'll take a look at:
  • Design-time errors
  • Run-Time errors
  • Logical errors
The longer your code gets, the harder it is to track down why things are not working. By the end of this section, you should have a good idea of where to start looking for problems. But bear in mind that debugging can be an art in itself, and it gets easier with practice.

Errors at Design-Time

Design-Time errors are ones that you make before the programme even runs. In fact, for Design-Time errors, the programme won't run at all, most of the time. You'll get a popup message telling you that there were build errors, and asking would you like to continue.
Design-Time errors are easy enough to spot because the C# software will underline them with a wavy coloured line. You'll see three different coloured lines: blue, red and green. The blue wavy lines are known as Edit and Continue issues, meaning that you can make change to your code without having to stop the programme altogether. Red wavy lines are Syntax errors, such as a missing semicolon at the end of a line, or a missing curly bracket in an IF Statement. Green wavy lines are Compiler Warnings. You get these when C# spots something that could potentially cause a problem, such as declaring a variable that's never used.

Blue Wavy Lines

In the image below, you can see that there's a blue wavy line under textBox2:
Blue Wavy Underline in C#
This is an Edit and Continue error. It's been flagged because the form doesn't have a control called textBox2 - it's called textBox1. We can simply delete the 2 and replace it with a 1. The programme can then run successfully. Holding your mouse over the wavy underline gives an explanation of the error. Some of these explanations are not terribly helpful, however!

Red Wavy Lines

These are Syntax errors. (Syntax is the "grammar" of a programming language, all those curly brackets and semicolons. Think of a Syntax error as the equivalent of programming spelling mistake.)
In the code below, we've missed out the semicolon at the end of the line:

Red Wavy Underline in C#
Holding the mouse pointer over the red wavy line gives the following message:
C# Error Explanation
It's telling us that a semicolon ( ; ) is expected where the red wavy underline is.
In the next image, we've missed out a round bracket for the IF Statement:
A Syntax Error in C#

Green Wavy Lines

These are Compiler Warnings, the C# way of alerting you to potential problems. As an example, here's some code that has a green wavy underline:
Green Wavy Underline
Holding the mouse pointer over the green underlines gives the following message:
Compiler Warning in C#
C# is flagging this because we have set aside some memory for the variable, but we're not doing anything with it.
This one is easy enough to solve, but some Compiler Errors can be a bit of a nuisance, and the messages not nearly as helpful as the one above!

Whatever the colour of the underline, though, the point to bear in mind is this: C# thinks it has spotted an error in your code. It's up to you to correct it!

Tuesday, July 27, 2010

C# Classes and objects

For Class and Objects Refer the following websites links:

1. devarticle website
2.  C# station
3. Aspfree
4.  Kirupa
5. Video 1
6. Video 2
7. Informit

Learn and Shine....!

C# program for Structure and Enumeration


using System;
using System.Collections.Generic;
using System.Text;

namespace structenumexample
{
class Program
{
enum Sem
{
Nil=0, First = 1, Second= 2,Third = 3, Fourth = 4, Fifth = 5, Sixth = 6
}
struct stud
{
int regno, m1, m2, m3, m4, m5, tot;
string name, result, perf;
float avg;
Sem sem;

public stud(int regno, int m1, int m2, int m3, int m4, int m5,string name,int sem)
{
this.regno = regno;
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
this.m4 = m4;
this.m5 = m5;
this.name = name;
this.avg = 0;
this.tot = 0;
this.result = "";
this.perf = "";
this.sem = (Sem) sem;
}

public void proce()
{
tot = m1 + m2 + m3 + m4+m5;
avg = tot / 5;
if ((m1 >= 40) && (m2 >= 40) && (m3 >= 40) && (m4 >= 40) && (m5 >= 40))
{
result = "PASS";
if (avg > 75)
perf = "Distinction";
else if (avg > 60)
perf = "First";
else if (avg > 50)
perf = "Second";
else
perf = "Third";
}
else
{
result = "FAIL";
perf = "Nil";
}

}
public void showres()
{
System.Console.WriteLine(" {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}", regno, name, sem,m1, m2, m3, m4, m5, tot, avg, result, perf);
}
}
public static void Main(string[] args)
{
int regno, m1, m2, m3, m4, m5;
string name;
int sem;
stud[] st = new stud[10];
int i;
for (i = 0; i < 10; i++)
{
Console.WriteLine("Enter the Regno of the student");
regno = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the Name of the student");
name = Console.ReadLine();
Console.WriteLine("Enter the Semester of the student (1/2/3/4/5/6)");
sem = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the m1 of the student");
m1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the m2 of the student");
m2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the m3 of the student");
m3 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the m4 of the student");
m4 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the m5 of the student");
m5 = Convert.ToInt32(Console.ReadLine());
st[i] = new stud(regno,m1,m2,m3,m4,m5,name,sem);
}
for (i = 0; i < 10; i++)
{
st[i].proce();
st[i].showres();
}
Console.ReadLine();
}
}
}

The above program is the example for the Structure and Enumeration usage in C#.

Tuesday, July 6, 2010

C# - Iterative Statements

Iterative statements repeat a particular statement block until a condition has been satisfied.

Following types of iterative statements are there in C#.

  • While
  • Do While
  • For
  • Foreach

From the above the while, for, foreach are the statements under the category of entry controlled looping. and the statement do while statement falls under the exit controlled looping.

The major difference between entry and exit controlled looping is the position where the condition is evaluated. Also in entry controlled looping, initially the condition is false the iterative block will not be executed even once, but in exit controlled looping, even if the condition is false, the iterative block is executed once and then only the condition is evaluated.

While Statement
The statement block of while statement is executed while the boolean expression is true. It may execute zero or more times. If the boolean expression is false initially, the statement block is not executed.

The while statement is used to iterate while the condition evaluates to true.

Do While Statement

Do While is almost similar to While statement except it validate its boolean expression after the statement block. It guranttees that the statement block shall run atleast once for sure. Further iterations of the statement block continues while the boolean expression is true.

For Statement
The For statement iterate a code block until a specified condition is reached similar to while statement. The only difference of for statement has over while statement is that for statement has its own built-in syntax for intiliazing, testing, and incrementing/decrementing (3 clauses) the value of a counter.
The first clause is the initialize clause in which the loop iterators are declared.
The second clause is the boolean expression that must evaluate to a boolean type and the statement block is repeated until this expression is false.
The third clause is to increment/decrement the value that is executed after each iteration.
All three clauses must be separated by a semicolon (;) and are optional. For statement block is repeated zero or more times based on the boolean expression validation (second clause).

ForEach Statement
ForEach statement is desiged to loop through a similar type of items in a collection. As each element is enumerated, the identifier is assigned the new element, and the statement block is repeated. The scope of the identifier is within the foreach statement block. The identifier must be of the same type extracted from the collection and is read-only.

for more details refer : Help 1 Help 2 Help 3 Help 4

C# interview Questions and Answers

C# interview Questions and Answers

  1. What’s the advantage of using System.Text.StringBuilder over System.String?
  2. Can you store multiple data types in System.Array?
  3. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
  4. How can you sort the elements of the array in descending order?
  5. What’s the .NET datatype that allows the retrieval of data by a unique key?
For more questions with answers visit : http://www.techinterviews.com/c-sharp-interview-questions-and-answers

Monday, July 5, 2010

C# - An Introduction

C# (pronounced C Sharp). C# is designed to be a simple, modern, general-purpose, object-oriented programming language, borrowing key concepts from several other languages, most notably Java.

C# could theoretically be compiled to machine code, but in real life, it's always used in combination with the .NET framework. Therefore, applications written in C#, requires the .NET framework to be installed on the computer running the application. While the .NET framework makes it possible to use a wide range of languages, C# is sometimes referred to as THE .NET language, perhaps because it was designed together with the framework.

C# is an Object Oriented language and does not offer global variables or functions. Everything is wrapped in classes, even simple types like int and string, which inherits from the System.Object class.
C# can be written with any text editor, like Windows Notepad, and then compiled with the C# Command line compiler, csc.exe, which comes with the .NET framework.
simple C# program looks likes as follows
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, world!");
Console.ReadLine();
}
}
for more details refer : http://csharp.net-tutorials.com/