0
0
C Sharp (C#)programming~15 mins

Variable declaration and initialization in C Sharp (C#) - Mini Project: Build & Apply

Choose your learning style9 modes available
Variable declaration and initialization
📖 Scenario: You are creating a simple program to store and display information about a book.
🎯 Goal: Learn how to declare variables and assign values to them in C#.
📋 What You'll Learn
Declare variables with correct types
Initialize variables with given values
Print variable values to the console
💡 Why This Matters
🌍 Real World
Storing and managing information about items like books is common in many software applications.
💼 Career
Understanding how to declare and initialize variables is a fundamental skill for any programming job.
Progress0 / 4 steps
1
Declare variables for book information
Declare a string variable called title and set it to "The Great Gatsby". Declare an int variable called year and set it to 1925.
C Sharp (C#)
Need a hint?

Use the syntax type variableName = value; to declare and initialize variables.

2
Add a variable for the author's name
Declare a string variable called author and set it to "F. Scott Fitzgerald".
C Sharp (C#)
Need a hint?

Remember to use string type for text values.

3
Declare a variable for the book price
Declare a double variable called price and set it to 10.99.
C Sharp (C#)
Need a hint?

Use double type for decimal numbers.

4
Print all book information
Use Console.WriteLine to print the variables title, author, year, and price each on a new line.
C Sharp (C#)
Need a hint?

Use Console.WriteLine(variableName); to print each variable.