将C程序转换为C#
我正在用c#编写Horspool算法。我有一个同样的c程序。我已经转换了大部分代码,但在转换几行代码时遇到了一些困难 我无法理解如何转换的代码行是将C程序转换为C#,c#,C#,我正在用c#编写Horspool算法。我有一个同样的c程序。我已经转换了大部分代码,但在转换几行代码时遇到了一些困难 我无法理解如何转换的代码行是 #define MAX 500 int t[MAX] 及 谁能告诉我如何把这些行转换成c 我的C程序代码的源代码是-#define MAX 500将是const int MAX=500 要在数组定义中使用MAX,可以使用如下内容: int[] t = new int[MAX]; string src; string p; int pos; Con
#define MAX 500
int t[MAX]
及
谁能告诉我如何把这些行转换成c
我的C程序代码的源代码是-#define MAX 500
将是const int MAX=500代码>
要在数组定义中使用MAX
,可以使用如下内容:
int[] t = new int[MAX];
string src;
string p;
int pos;
Console.Clear();
Console.WriteLine("Enter the text in which pattern is to be searched:\n");
src = Console.ReadLine();
要转换为C#的行如下所示:
int[] t = new int[MAX];
string src;
string p;
int pos;
Console.Clear();
Console.WriteLine("Enter the text in which pattern is to be searched:\n");
src = Console.ReadLine();
您只需要string s=Console.ReadLine()代码>谢谢,你能告诉我如何转换#定义最大500 int t[MAX]
?谢谢,我添加了常量int MAX=500
但是我想在数组中使用MAX
,我该如何写int t[MAX]
?@Dazzlerint[]t=new int[MAX]
谢谢@diiN_u的回答:)谢谢@psionix的回答:)