Navigation

Related Articles

Back to Latest Articles

C# Basics – Random Numbers, Chars and Strings – Part 7

We introduce data types like strings and chars in C# programming language


Andraz Krzisnik
C# Basics – Random Numbers, Chars and...

Random Numbers

To generate a random number, we will use a constructor called Random. Then to generate a random number we will use either .Next() or .NextDouble() function.

Char Data Type

We can store a value to a variable that is just a single symbol by itself. These type of variables are called char – short for character. We can store symbols such as lowercase letters, uppercase letters, all numerals, special symbols like dot or comma and many more. When declaring a char it is important to write with single quotes (Example: ‘a’).

Strings

Strings are very useful data type, because we almost always work with strings when we work with data that is not numerical. For example names and addresses. But they are useful for more than just that.

How do we declare a string?

It’s important that you put any kind of string value between double quotes.

We can also access each letter in a string like we would access values in an array. So string is an array of each individual characters.


Download Examples Next Chapter
Show Comments (2)

Comments

  • furtdsolinopv

    We’re a group of volunteers and starting a new scheme in our community. Your website provided us with valuable information to work on. You’ve done a formidable job and our entire community will be thankful to you.

    • Article Author
    • Reply
  • Cuckold Cams

    This piece of writing gives clear idea for the new visitors of blogging, that genuinely how to do blogging and site-building.

    • Article Author
    • Reply

Related Articles

C# Basics

C# Basics – Constructors – Part 12

Constructors Sometimes we want to create an object and set some predetermined state to it. Basically, you would pass the properties’ values as an argument to an object when you...

Posted on by Andraz Krzisnik
C# Basics

C# Basics – Writing Code – Part 2

When we create a project, first thing we will see are a bunch of windows. Let’s talk about what each of these windows do: Editor is a window meant for writing code Solution...

Posted on by Andraz Krzisnik