Blog

  • Declare variables

    A literal is literally a hard-coded value. Hard-coded values are values that are constant and unchanged throughout the execution of the program. However, most applications will require you to work with values that you don’t know much about ahead of time. In other words, you’ll need to work with data that comes from users, from files, or from across the network.

    When you need to work with data that isn’t hard-coded, you’ll declare a variable.

    What is a variable?

    variable is a container for storing a type of value. Variables are important because their values can change, or vary, throughout the execution of a program. Variables can be assigned, read, and changed. You use variables to store values that you intend to use in your code.

    A variable name is a human-friendly label that the compiler assigns to a memory address. When you want to store or change a value in that memory address, or whenever you want to retrieve the stored value, you just use the variable name you created.

    Declare a variable

    To create a new variable, you must first declare the data type of the variable, and then give it a name.

    C#Copy

    string firstName;
    

    In this case, you’re creating a new variable of type string called firstName. From now on, this variable can only hold string values.

    You can choose any name as long as it adheres to a few C# syntax rules for naming variables.

    Variable name rules and conventions

    A software developer once famously said “The hardest part of software development is naming things.” Not only does the name of a variable have to follow certain syntax rules, it should also be used to make the code more human-readable and understandable. That’s a lot to ask of one line of code!

    Here’s a few important considerations about variable names:

    • Variable names can contain alphanumeric characters and the underscore character. Special characters like the hash symbol # (also known as the number symbol or pound symbol) or dollar symbol $ are not allowed.
    • Variable names must begin with an alphabetical letter or an underscore, not a number.
    • Variable names are case-sensitive, meaning that string Value; and string value; are two different variables.
    • Variable names must not be a C# keyword. For example, you cannot use the following variable declarations: decimal decimal; or string string;.

    There are coding conventions that help keep variables readable and easy to identify. As you develop larger applications, these coding conventions can help you keep track of variables among other text.

    Here are some coding conventions for variables:

    • Variable names should use camel case, which is a style of writing that uses a lower-case letter at the beginning of the first word and an upper-case letter at the beginning of each subsequent word. For example, string thisIsCamelCase;.
    • Variable names should begin with an alphabetical letter. Developers use the underscore for a special purpose, so try to not use that for now.
    • Variable names should be descriptive and meaningful in your app. Choose a name for your variable that represents the kind of data it will hold.
    • Variable names should be one or more entire words appended together. Don’t use contractions or abbreviations because the name of the variable (and therefore, its purpose) may be unclear to others who are reading your code.
    • Variable names shouldn’t include the data type of the variable. You might see some advice to use a style like string strValue;. That advice is no longer current.

    The example string firstName; follows all of these rules and conventions, assuming you want to use this variable to store data that represents someone’s first name.

    Variable name examples

    Here’s a few examples of variable declarations using the data types you learned about thus far:

    C#Copy

    char userOption;
    
    int gameScore;
    
    decimal particlesPerMillion;
    
    bool processedCustomer;
    

    Recap

    Here’s what you’ve learned so far about variables:

    • Variables are temporary values you store in the computer’s memory.
    • Before you can use a variable, you have to declare it.
    • To declare a variable, you first select a data type for the kind of data you want to store, and then give the variable a name that follows the rules.

    Now that you know how to declare a variable, let’s learn how to set, retrieve, and initialize the value of a variable.

    https://lernix.com.my/red-hat-certification-malaysia

  • Review the solution

    The following code is one possible solution for the challenge from the previous unit.

    C#Copy

    Console.WriteLine("This is the first line.");
    
    Console.Write("This is ");
    Console.Write("the second ");
    Console.Write("line.");
    

    This code is just one possible solution, among many possible ways to achieve the same result. However, you should have used both methods to produce the desired output.

    OutputCopy

    This is the first line.
    This is the second line.
    

    If you were successful, congratulations! Continue to the next unit for a knowledge check.

     Important

    If you had trouble completing this challenge, review the previous units before you continue.

    https://lernix.com.my/veeam-certification-malaysia

  • Complete the challenge

    Code challenges throughout these modules will reinforce what you’ve learned and help you gain some confidence before continuing on.

    Challenge: Write code in the .NET Editor to display two messages

    1. Select all of the code in the .NET Editor, and press Delete or Backspace to delete it.
    2. Write code that produces the following output:OutputCopyThis is the first line. This is the second line. In the previous unit, you learned how to display a message in just one line of code, and you learned how to display a message using multiple lines of code. Use both techniques for this challenge. It doesn’t matter which technique you apply to which line, and it doesn’t matter how many ways you split one of the messages into multiple lines of code. That’s your choice.No matter how you do it, your code should produce the specified output.

    https://lernix.com.my/lpi-linux-administration-certification-training-courses-malaysia

  • Learn how it works

    To understand how your code works, you need to step back and think about what a programming language is. Consider how your code communicates commands to the computer.

    What is a programming language?

    Programming languages like C# let you write instructions that you want the computer to carry out. Each programming language has its own syntax, but after learning your first programming language and attempting to learn another one, you’ll quickly realize that they all share many similar concepts. A programming language’s job is to allow a human to express their intent in a human-readable and understandable way. The instructions you write in a programming language are called “source code” or just “code”. Software developers write code.

    At this point, a developer can update and change the code, but the computer can’t understand the code. The code first must be compiled into a format that the computer can understand.

    What is compilation?

    A special program called a compiler converts your source code into a different format that the computer’s central processing unit (CPU) can execute. When you used the green Run button in the previous unit, the code you wrote was first compiled, then executed.

    Why does code need to be compiled? Although most programming languages seem cryptic at first, they can be more easily understood by humans than the computer’s preferred language. The CPU understands instructions that are expressed by turning thousands or millions of tiny switches either on or off. Compilers bridge these two worlds by translating your human-readable instructions into a computer-understandable set of instructions.

    What is syntax?

    The rules for writing C# code is called syntax. Just like human languages have rules regarding punctuation and sentence structure, computer programming languages also have rules. Those rules define the keywords and operators of C# and how they are put together to form programs.

    When you wrote code into the .NET Editor, you may have noticed subtle changes to the color of different words and symbols. Syntax highlighting is a helpful feature that you’ll begin to use to easily spot mistakes in your code that don’t conform to the syntax rules of C#.

    How did your code work?

    Let’s focus on the following line of code you wrote:

    C#Copy

    Console.WriteLine("Hello World!");
    

    When you ran your code, you saw that the message Hello World! was printed to the output console. When the phrase is surrounded by double-quotation marks in your C# code, it’s called a literal string. In other words, you literally wanted the characters Hello, and so on, sent to the output.

    The Console part is called a class. Classes “own” methods; or you could say that methods live inside of a class. To visit the method, you must know which class it’s in. For now, think of a class as a way to represent an object. In this case, all of the methods that operate on your output console are defined inside of the Console class.

    There’s also a dot (or period) that separates the class name Console and the method name WriteLine(). The period is the member access operator. In other words, the dot is how you “navigate” from the class to one of its methods.

    The WriteLine() part is called a method. You can always spot a method because it has a set of parentheses after it. Each method has one job. The WriteLine() method’s job is to write a line of data to the output console. The data that’s printed is sent in between the opening and closing parenthesis as an input parameter. Some methods need input parameters, while others don’t. But if you want to invoke a method, you must always use the parentheses after the method’s name. The parentheses are known as the method invocation operator.

    Finally, the semicolon is the end of statement operator. A statement is a complete instruction in C#. The semicolon tells the compiler that you’ve finished entering the command.

    Don’t worry if all of these ideas and terms don’t make sense. For now, all you need to remember is that if you want to print a message to the output console:

    • Use Console.WriteLine("Your message here");
    • Capitalize ConsoleWrite, and Line
    • Use the correct punctuation because it has a special role in C#
    • If you make a mistake, just spot it, fix it and re-run

     Tip

    Create a cheat sheet for yourself until you’ve memorized certain key commands.

    Understand the flow of execution

    It’s important to understand the flow of execution. In other words, your code instructions were executed in order, one line at a time, until there were no more instructions to execute. Some instructions will require the CPU to wait before it can continue. Other instructions can be used to change the flow of execution.

    Now, let’s test what you’ve learned. Each module features a simple challenge, and if you get stuck, you’ll be supplied with a solution. In the next unit, you’ll get a chance to write some C# on your own.

    https://lernix.com.my/nodejs-training-courses-malaysia

  • What is cloud computing

    Cloud computing is the delivery of computing services over the internet. Computing services include common IT infrastructure such as virtual machines, storage, databases, and networking. Cloud services also expand the traditional IT offerings to include things like Internet of Things (IoT), machine learning (ML), and artificial intelligence (AI).

    Because cloud computing uses the internet to deliver these services, it doesn’t have to be constrained by physical infrastructure the same way that a traditional datacenter is. That means if you need to increase your IT infrastructure rapidly, you don’t have to wait to build a new datacenter—you can use the cloud to rapidly expand your IT footprint.

    This short video provides a quick introduction to cloud computing.

    https://learn-video.azurefd.net/vod/player?id=09d13868-cf87-4b06-90eb-29bf1fbed6ec&locale=en-us&embedUrl=%2Ftraining%2Fmodules%2Fdescribe-cloud-compute%2F3-what-cloud-compute

    https://lernix.com.my/vmware-vsphere-certification-training-courses-malaysia