--------------------

STATE.TXT 

create#action#http://127.0.0.1:8011/create
add#action#http://127.0.0.1:8012/add
fetch#action#http://127.0.0.1:8013/fetch

----------------------

const string cStateFile = "STATE.TXT";

        static void Main(string[] args)
        {
            Dictionary<string, string> State = new Dictionary<string, string>();</string, string></string, string>
            foreach (var line in File.ReadAllLines(cStateFile))
            {
                var str = line.Split('#');
                var name = str[0];
                var action = str[1];
                var url = str[2];
                State[name] = action + " " + url;
            }

            string cmd;
            while ((cmd = Console.ReadLine()) != null)
            {
                Console.WriteLine(State[cmd]);
            }

        }

 

나눠서 볼 것 

 

1)
Dictionary<string, string> State = new Dictionary<string, string>();


2) 
while ((cmd = Console.ReadLine()) != null)
{
Console.WriteLine(State[cmd]);
}

3) 
const string cStateFile = "STATE.TXT";

foreach (var line in File.ReadAllLines(cStateFile))

4) 
// line //
create#action#http://127.0.0.1:8011/create
add#action#http://127.0.0.1:8012/add
fetch#action#http://127.0.0.1:8013/fetch
//

var str = line.Split('#');
var name = str[0];
var action = str[1];
var url = str[2];
State[name] = action + " " + url;

'프로그래밍 > C#' 카테고리의 다른 글

sample #2 .. No 3  (0) 2025.05.31
sample #2 .. No 2  (0) 2025.05.31
이것저것  (0) 2024.06.12
클라이언트 서버 예제 3  (0) 2024.05.14
클라이언트 서버 예제 2  (0) 2024.05.14

+ Recent posts