-4
public class Europe
{
    uint Value1 = 0x12345;
}

public class UnitedStates
{
    uint Value1  = 0x54321;
}




    private uint Region(object Value)
    {
        if (EuropeCB.Checked)
        {
            return Europe.Value;    
        }
        else 
        {
            return UnitedStates.Value;
        }
    }

How do i go about doing this since it doesnt parse the value as a request for the value that was enterd in the function, you guys got any idea how i can solve this

Further explained

All i want is the uint value returned from 1 of the classes using teh same identifier withing the class

so as you can see there are 2 classes "Europe" and "UnitedStates"

and with the checkbox "EuropeCB" active i want the function Region to return from Class "Europe"instead of "UnitedStates"

So a Call will look like Region(Value1)

With "EuropeCB" checked it should return 0x12345 else it should return 0x54321

P.S it errors on "return Europe.Value" & "return UnitedStates.Value" it says "Class does not contain a definition for value"

  • Probably not a good idea. Either create a `Region` base class and inherit from it, or simply make Region a property of a more general class, or even use an enum. All of these are better options. – Robert Harvey Nov 02 '14 at 14:32
  • 2
    Talk about lack of context. What is `Region`, where does it come from, and what is `Value`, where does it come from and what is `Value`'s relationship with the returned value? What is this supposed to do and who calls it (since it's private)? And why are you trying to use a static context when the `Value1`s are instance fields? – lc. Nov 02 '14 at 14:32
  • You should really use Enums for that. – IS4 Nov 02 '14 at 14:43

1 Answers1

0

Make them static.

public class Europe
{
    public static uint Value1 = 0x12345;
}

public class US
{
    public static uint Value1  = 0x54321;
}
Saverio Terracciano
  • 3,885
  • 1
  • 30
  • 42
  • Need to make them public also. – Magnus Nov 02 '14 at 14:34
  • All i want is the uint value returned from 1 of the classes using teh same identifier withing the class so as you can see there are 2 classes "Europe" and "UnitedStates" and with the checkbox "EuropeCB" active i want the function Region to return from Class "Europe"instead of "UnitedStates" So a Call will look like Region(Value1) With "EuropeCB" it should return 0x12345 else it should return 0x54321 – Laurens Zalm Nov 02 '14 at 14:55
  • @LaurensZalm despite your design being flawed, I suppose that if you change your code according to what it's written in this answer, you should achieve what you want. – Saverio Terracciano Nov 02 '14 at 16:53