Question

Describe the "simple" mechanism that we use in C# to store values in memory while our...

Describe the "simple" mechanism that we use in C# to store values in memory while our programs are running. Give a simple example (an actual statement) that names storage in our program and places a value in the named memory location.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In C#, Values are stored either in Value Data types or Reference Data Types. Variables of type 'Value Datatype' and 'Reference Data Types' are created to store values in memory.C# compiler implicitly maps the name of variable to address location in memory where value will be stored.

Value Data types refers to variables of type int,char,bool,float etc.

Ex: int number=20;

int x=number;

Here 20 is stored in address location X123 .whenever number variable is used in the program like "x=number",compiler maps number variable to address 'X123' and reads the value from the memory location and assigns the value to x variable.

Similarly ,statement like (number=20 )=> compiler maps number variable to address 'X123' and stores the value in the memory location

Reference Data types contains value Data types and complex datatypes.

Ex:

public class Test{

int x;

float y;

Test t ; //Reference Data Type

}

A variable is a name given to storage area that programm's use for manipulation.Each variable has a specific type, size, range of values that can be stored within that memory, set of operations that can be applied.

C# Example

Public class Test

{

public Static void main()

{

int x = 100;

int *ptr = & x;

Console.WriteLine((int)ptr) // Displays the memory address  

Console.WriteLine(*ptr) //Displays the value at address

}

}

Add a comment
Know the answer?
Add Answer to:
Describe the "simple" mechanism that we use in C# to store values in memory while our...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Describe repetition structure. Identify 3 statements that we use in C# to add repetition to our...

    Describe repetition structure. Identify 3 statements that we use in C# to add repetition to our programs.

  • Please use C# For this project, we will see what it's like to write a simple...

    Please use C# For this project, we will see what it's like to write a simple windows application program that we can perform easily in our heads. You'll find that writing programs is similar to explaining things to a 5-year-old. You are to make this program "user friendly". In other words, make sure valid data has been entered. You are to create a simple change program. The user enters the amount due and the amount tendered. You are to calculate...

  • This assignment will continue our hardware store system. You will turn in a java file named...

    This assignment will continue our hardware store system. You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be exactly as specified (including method names): getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user...

  • B. Which statement would be used to define a to element integer array c? a. Array...

    B. Which statement would be used to define a to element integer array c? a. Array c = int[10]; b. C = int[10]; c. int Array c[10]; d. int c[10]; 17. Declare an Integer pointer variable named int_ptr. 18. Use the pointer created in question 17 and assign it the memory location of a variable named int_var. 19. Suppose you have an executable program named count that counts the characters in its input. Devise a command-line command using the count...

  • In C Programming: Declare a minimum size data structure to store the values of a Sudoko...

    In C Programming: Declare a minimum size data structure to store the values of a Sudoko puzzle (suppose empty cells will have the value of 0 while the other cells will have values from 1 to 9). Then ask user if he/she wants to enter data for a sudoku puzzle or a sudoku solution. Suppose user enters 1 to enter a puzzle; or 2 to enter a solution to be checked. Write/call a function that asks user to enter the...

  • c++ Note: Do not use using namespace std; Use std:: Use comments for clear understanding TEST...

    c++ Note: Do not use using namespace std; Use std:: Use comments for clear understanding TEST THE PROGRAM. 1) Create a c++ program to run a simple experiment to see how reference parameters work. 2) You need to add a “&” symbol after the parameter type specification to set up a reference parameter: int myfunc (int & x) { x = 11; return -11; } int testdata = 0; int y; y= myfunc (testdata); 3) Now, You can get a...

  • In JAVA While out on a standard run we stop in at our ‘local’ fence and...

    In JAVA While out on a standard run we stop in at our ‘local’ fence and try to sell some of our items. When we board his ship we notice that we are the only people on board, so we instantly start grabbing things and loading them on our ship and get ready to run. While grabbing things we realize that we are going to run out of space extremely quickly and we should prioritize what we grab to maximize...

  • Your task is to write a C++ program that consumes integer values as command line arguments...

    Your task is to write a C++ program that consumes integer values as command line arguments and returns the arithmetic mean of these values. To increase the flexibility of the program, there should be no set number of arguments. To overcome this, we will require the argument argv[1] to be the number of integers the user enters. For example, if the user wants to calculate the arithmetic mean of 4 numbers, they would pass in 4 as the first argument...

  • Introduction: One of the most important uses of pointers is for dynamic allocation of memory. In...

    Introduction: One of the most important uses of pointers is for dynamic allocation of memory. In C++ there are commands that let the user request a chunk of memory from the operating system, and use this memory to store data. There are also commands to return memory back to the O/S when the program is finished using the data. In this lab, we will explore some of the things that can go wrong when using dynamic memory and discuss how...

  • We are running programs on a machine where values of type int have a 32-bit two’s-complement...

    We are running programs on a machine where values of type int have a 32-bit two’s-complement representation. Values of type float use the 32-bit IEEE format, and values of type double use the 64-bit IEEE format. We generate arbitrary integer values x, y, and z, and convert them to values of type double as follows: /* Create some arbitrary values */ int x = random(); int y = random(); int z = random(); /* Convert to double */ double dx...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT