Solved

K. C#3 3 Struct q.

Posted on 2006-06-24
2
161 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

929 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

14 Experts available now in Live!

Get 1:1 Help Now