© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
38 replies
Theos

❔ Pass variable type as class parameter

Hey, so basically I have a class
class Number
{
  public string Type;
  public string Value;

  public Number(string type, string value)
  {
    Type = type;
    Value = value;
  }
}
class Number
{
  public string Type;
  public string Value;

  public Number(string type, string value)
  {
    Type = type;
    Value = value;
  }
}


What I want to do is if I do this for example
var num = new Number("long", "10000");
var num = new Number("long", "10000");

Number.Type shouldnt be string but rather a
long
long
;
and Number.Value should contain the value
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Class with parameter as a generic parameter
C#CC# / help
4y ago
❔ Use Variable as Type
C#CC# / help
3y ago
✅ Pass status as parameter in controller
C#CC# / help
3y ago