4
4
4elovek_20152018-06-08 18:20:36
C++ / C#
4elovek_2015, 2018-06-08 18:20:36

How to pass the value of a local variable to a global one?

Hello.
In general there is a code

static void Main(string[] args)
        {
    string url = "ссылка";
              using (var webClient = new WebClient())
              {
            var response = webClient.DownloadString(url);
                string srt = "dasda";
                if (response.Contains("RTF_WRM=") == true)
                {
                    Regex regex = new Regex(@"R\d{12}");
                    MatchCollection matches = regex.Matches(response);
                    if (matches.Count > 0)
                    {
                        foreach (Match match in matches)
                        {
                            Console.WriteLine(match.Value);
                            srt = match.Value;
                        }
                    } 
                }
            }
        }

How do I pass the value of the variable srt = match.Value; in static void Main2(string[] args) ?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#, 2018-06-08
@mindtester

1 - there are no global variables in the sharp
2 - if "another lane" is also on the sharp, but in another project, well, call it with parameters, what's the problem? <project_name>.Main(new string[] { param0, param1, ....}); only in the main project you need to add a link to the secondary
3 - or run as an external process, and form a line of call parameters, an example is here

V
VoidVolker, 2018-06-08
@VoidVolker

https://docs.microsoft.com/en-us/dotnet/csharp/pro...

4
4elovek_2015, 2018-06-08
@4elovek_2015

I am not very strong in C#, I want to learn.
I wanted to download that I have static void Main(string[] args) and static void Main1(string[] args)
So how do I make static void Main(string[] args) see the variable from static void Main1(string [] args) - srt = match.Value;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question