• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

K. C#3 3 Struct q.

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)

        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);

1 Solution
Carl TawnSystems and Integration DeveloperCommented:
They're all correct.

Are you having an issue with any of them, or did you just want someone to double check them ?
noam_dzAuthor Commented:
double check
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now