[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

K. C#3 3 Struct q.

Posted on 2006-06-24
2
Medium Priority
?
188 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 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