سلام بر تمامی برنامه نویسان سی شارپ 😉 در این مطلب از وب سایت پروگرم 98 کد استفاده از رشته (string) در switch و case در سی شارپ #C را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی کد به این صورت می باشد :
12321
کد استفاده از رشته (string) در switch و case در سی شارپ #C :
using System;
class MainClass {
public static void Main() {
string[] strs = { "one", "two", "three", "two", "one" };
foreach(string s in strs) {
switch(s) {
case "one":
Console.Write(1);
break;
case "two":
Console.Write(2);
class MainClass {
public static void Main() {
string[] strs = { "one", "two", "three", "two", "one" };
foreach(string s in strs) {
switch(s) {
case "one":
Console.Write(1);
break;
case "two":
Console.Write(2);