Solved

K. C#3 3 Struct q.

Posted on 2006-06-24
2
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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