Solved

K. C#3 3 Struct q.

Posted on 2006-06-24
2
158 Views
Last Modified: 2012-05-05
I am learning c# via KeyStone CBT.
But the CBT contains excresises without answers.
Here are my answers.
The build runes OK.


using System;

namespace structNamespace
{

    public struct MyStruct
    {
//1. Define a public struct with the name MyStruct with a default Constructor.  3.2
    }


    public struct Region
    {
    //2. Define a public struct called Region that defines two private strings, City and State.  Next, add a Constructor that accepts those string parameters.  Lastly, add a method that concatenates those strings and gives you the normal City, State format.  3.2
        private string City;
        private string State;

        public Region (string City,string State)
        {
            this.City=City;
            this.State=State;
        }

        public string GetRegion()
        {
            return City + "," + State;
         }
    }

 
 //   Region region= new Region("boston","California");

    //4. Define a class called CallStruct that uses the Region struct.  Have it send Region the parameters it needs for its constructor and for instantiation, then call the GetRegion method of the Region struct to return the values you set it.  3.3
    class callStruct
    {
        static void Main(string[] args)
        {
            Region region= new Region("boston","California");
           
            String writeRegion = region.GetRegion ();

     //5. Use the {0} syntax in two WriteLine statements designed to output to the console the Region information obtained in the preceding Exercise.  3.3

            Console.WriteLine ("the region is {0}",writeRegion);
        }
    }
}

0
Comment
Question by:noam_dz
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 125 total points
ID: 16974699
They're all correct.

Are you having an issue with any of them, or did you just want someone to double check them ?
0
 
LVL 4

Author Comment

by:noam_dz
ID: 16974923
double check
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now