© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
-Epitaph-

How do I use a string from one class to another?

using System;
using System.Net.Http;
using System.Threading.Tasks;

public class Keys {
  public static void Main (string[] args) {
    
    public string APIKey = "Key";
    
    public string URL = $"example.com/key={APIKey}";
    
  }
}

class Call {
  static async Task Main(string[] args) {
    using (HttpClient client = new HttpClient()) {
      HttpResponseMessage response = await client.GetAsync(Keys.URL);
      string result = await response.Content.ReadAsStringAsync();
      Console.WriteLine(result);
    }
    
  }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class Keys {
  public static void Main (string[] args) {
    
    public string APIKey = "Key";
    
    public string URL = $"example.com/key={APIKey}";
    
  }
}

class Call {
  static async Task Main(string[] args) {
    using (HttpClient client = new HttpClient()) {
      HttpResponseMessage response = await client.GetAsync(Keys.URL);
      string result = await response.Content.ReadAsStringAsync();
      Console.WriteLine(result);
    }
    
  }
}


with something like this, how can I use
URL
URL
which is on
Keys
Keys
unto
Call
Call
?
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

✅ use one string if a condition is true, else use another string
C#CC# / help
3y ago
How do i pass data from one form to another?
C#CC# / help
4y ago
❔ ✅ How to call a specific attribute from a getter class to another class
C#CC# / help
3y ago
❔ How to access variable from another class?
C#CC# / help
3y ago