VARIABLE C# HELP

Asked

Viewed 64 times

-3

Good afternoon, someone can help me in a code?

using System;
using System.Collections.Generic;

namespace Launcher.WesT
{    
    class Globals
    {

        private Config Configs_ = null;
        public string URLL()
        {
            Configs_ = Config.GetConfigs();
            Configs_.LoadLocalConfig("config.wz", "21456");
            string SITE = Configs_.LINKUP;

            return (SITE);
        }

        public static string ServerURL = URLL();

how do I make for that line public Static string Serverurl = URLL();

read the URLL()?

from now on thanks.

2 answers

2


The method URLL() is not static.

An alternative is to leave him static.

Or keep as you are and leave the variable valueless, and in a given non-Static method you assign using ServerURL = this.URLL();


If you know English, this site can be useful:

C# - Static

  • put the answer so, do not know use this site yet kkkkk, thanks msm

  • 2

    Take a look at the tour, I’m sure you’ll love Stackoverflow when you learn everything he has to offer. :)

1

public static Config Configs_ = null;  //<-- STATIC q nao tinha

        public static string URLL()
        {
            Configs_ = Config.GetConfigs();
            Configs_.LoadLocalConfig("config.wz", "21456");
            string SITE = Configs_.LINKUP;

            return (SITE);
        }

        public static string ServerURL = URLL();

I did so and it seems that it worked, I had to put Static in public static Config Configs_ = null;tbm

since thanks, if anyone tever tbm some other solution q can help thank you..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.