1 Replies - 935 Views - Last Post: 14 March 2012 - 02:37 PM Rate Topic: -----

#1 mobilenvironment  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 21-February 11

C# Passing values with objects and classes

Posted 14 March 2012 - 02:30 PM

In this program using C# I created a class called "AddressClass" and I am attempting to pass values through an 'object' that I created called "Address1". I am a beginner with classes and objects and need some help to get a general idea on how to pass values.

Main Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyAddress
{
    class Address
    {
        static void Main(string[] args)
        {
            AddressClass Address1 = new AddressClass("1215 Main St, Miami, Florida");
            Address1.Display();
        }
    }
}



Address Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyAddress
{
    class AddressClass
    {
        private string Address;
        private string City;
        private string State;

        public void AddressClass(string ADDRESS, string CITY, string STATE)
        {
          Address = ADDRESS;
          City = CITY;
          State = STATE;
        }

        public void Display()
        {
          Console.Writeln(Address);
          Console.Writeln(City);
          Console.Writeln(State);
        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: C# Passing values with objects and classes

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,662
  • Joined: 02-June 10

Re: C# Passing values with objects and classes

Posted 14 March 2012 - 02:37 PM

See FAQ # 3. (Click the SHOW button below)


TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class/Form2


FAQ (Frequently Asked Questions - Updated Feb 2012
Spoiler



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1