Hỏi đáp
Chia sẻ kiến thức, cùng nhau phát triển
Xin hướng giải quyết, tình hình là sau khi tách ra đc 123, mình muốn gán biến "123" vào 1 biến int để tính toán trên hàm main, mong đc giúp đỡ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ConsoleApp2
{
internal class Program
{
static void Main(string [] b)
{
demo();
Console.ReadKey();
}
public static void demo()
{ string b = "";
Regex reg = new Regex(@"\d");
string c = "";
string[] A = new string[10];
int i = 0;
int d=0;
foreach (Match test in reg.Matches("-ewfasd 123"))
{
b = test.ToString();
A[i] = b;
i++;
}
for (int j = 0; j < A.Length; j++)
{
c = String.Concat(c, A[j]);
}
d=int.Parse(c);
Console.WriteLine(c);
}
} }
Bạn tự phát triển tiếp nhé: