Question not got output- it says 3 warning

Rakesh Tiwari

New member
Joined
Feb 28, 2020
Messages
2
Programming Experience
Beginner
C#:
using System;

namespace DataTypeApplication
{
    class Area
    {
        public int Length;
        public int width;
        public int Res;
    }

    class Function
    {
        static void Main(string[] args)
        {
            int Length = 23;
            int width =10;

            int Res  = Length * width;

            Area a = new Area();
            Console.WriteLine(a.Res);
            Console.ReadLine();
 
Last edited by a moderator:
A brief title and some code are not enough. The post needs to contain a FULL and CLEAR explanation of the problem and the title should summarise that. I suspect that English is not your first language, which makes it harder, but you need to try harder. If you are saying that the compiler generates three warnings from your code then you need to specify what lines the warnings are on and what the warning messages are.

That said, why would you think it useful to display the Res field of an Area object that you just created when you've never set that field, while simultaneously ignoring a local variable that you did just set? Why do you expect to get any output from that Area object when you never put any data in? If you want to use that object then use it. Don't use local variables instead.
 
Back
Top Bottom