Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Type Casting Practice | Dealing with Data Types
C# Basics
course content

Kursinnhold

C# Basics

C# Basics

1. Getting Started
2. Dealing with Data Types
3. Control Structures
4. Loops
5. Arrays
6. Methods

book
Type Casting Practice

Store the value number in the variables n1 and n2. Use explicit type casting if needed.

cs

main

copy
1234567891011121314151617181920
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = ___; double n2 = ___; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }

Use type casting only on the long variable.

cs

main

copy
1234567891011121314151617181920
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { float number = 14.47f; // Change code below this line long n1 = (long) number; double n2 = number; // Change code above this line Console.WriteLine(n1); Console.WriteLine(n2); } } }

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 12
Vi beklager at noe gikk galt. Hva skjedde?
some-alt