What’s the Deal with C#?
When I first started my educational journey in web development, I was 99% convinced I was a Python developer at heart. The syntax was simple, and I found that using frameworks and libraries could push me toward creating some super cool things. I even started developing my own web app with it using the Django framework. However, something happened along the way. C# grabbed onto me and didn’t let go.
Let’s back up for a minute, though.
I’m not great lover of Microsoft products, if I’m being honest. I use it regularly for some development tasks I need to do, but my preferred operating system is MacOS. My experience with it is that it’s much more stable, secure, reliable, less buggy, and capable of standing the test of time. Microsoft has been quite the opposite for me. So, with that said, when I first started learning C# and .NET during my software development boot camp, I had already decided I would just go through the motions.
But there was something about it that made me want to invest my time into a deeper dive.
C# Basics
C# is an object-oriented programming language that can be used to develop desktop software, websites, web applications, mobile and tablet applications, games, and smart TV applications. The syntax isn’t as easy as some other languages, but it’s not challenging to learn. Here’s an example code snippet of a console application that prints a message to the console:
string message = “This message will print on the console.”;
Console.WriteLine(message);
Console.ReadLine();
This code will print the message on the screen, then wait for the user to press a key to close out the terminal window.
Most C# developers use Microsoft’s Visual Studio to build their programs and apps, and it’s really quite a powerful development tool.
The .NET Framework
As a developer, you’ll likely use many frameworks and libraries that will make your job a hell of a lot easier. (Frameworks provide the bigger picture for your program. Libraries give you access to specific code that contribute to your unique solution.) With C#, .NET is one framework you’ll use consistently because of its heavy integration with the C# programming language.
The .NET framework allows you to build the following types of applications:
- Web
- Mobile
- Desktop
- Microservices
- Cloud
- Machine Learning
- Game Development
- Internet of Things (IoT)
Each time you start a new project on Visual Studio, you’ll tell it exactly what type of application you’re developing, and it automatically adds everything you need to make it work, often building dozens or even hundreds of lines of code with the click of a button.
.NET Core
This is another framework commonly used in C# applications. What differentiates it from the standard .NET framework is that it can be used to build cross-platform applications. It has the following components embedded in the framework:
- Command Line Interface (CLI) Tools
- Language Compiler [Roslyn]
- Set of Libraries [CoreFX]
- Command Language Runtime (CLR) Environment [CoreCLR]
ASP.NET
Are you ready for this? ASP.NET is yet another framework commonly used when developing with C#. It is a powerful web framework that makes creating websites and web applications much easier by extending the .NET framework. One of its more common uses is providing the structure for an MVC application.
Model-View-Controller (MVC) Basics
MVC is a design pattern that separates each aspect of a web application into a specific function. Each of these layers has its own role to play within the application.
Model
The model hosts the data your application needs to solve a problem or perform a task. A basic model would create a class that defines the type of data your application needs to allow the user to achieve something. An example model for defining attributes of a student might look something like this:
public class Student
{
int studentID { get; set; }
string firstName { get; set; }
string lastName { get; set; }
string email { get; set; }
string addressOne { get; set; }
string addressTwo { get; set; }
string city { get; set; }
string state { get; set; }
string zipCode { get; set; }
}
This part of your app is generally used to design your database that the rest of the program needs to accomplish an array of tasks.
View
The view portion of your application is how you will present the data to the user. With ASP.NET, this will be done through a .cshtml file where you will code what that specific webpage looks like, using HTML code and Razor syntax that gives your views the ability to embed server-side code into the page.
Controller
The controller allows the views and the models to talk to each other through the business logic you create in your code. It’s where the bulk of your C# code will live as you develop your web application. Here are some of the things you’ll do in the controller:
- Display your webpages
- Connect to your database
- Add data to your database
- Display data from your database
- Add user authentication
- Connect and interact with APIs
Job Outlook for C# Developers
Software development, in general, is seeing consistent growth on the job market. Though there aren’t as many companies hiring today as in the recent past, there’s still quite a lot of opportunity out there, and C# is one of the primary skills employers look for. As an example, about 20 to 25% of the jobs available on Indeed.com for software development ask for some knowledge and/or experience of the language. And that doesn’t account for the companies hiring quietly.
This is one of the reasons I focus my continual self-education on C#, .NET, and ASP.NET; however, it’s not the most important reason for me. One of the most important reasons is the fact that I love developing anything in the language, and that passion for it continues to grow.
One Comment