小编Joh*_*hok的帖子

C# 数组范围

我是 C# 新手,无法理解变量的范围。我在课程开始时声明了一个数组:

namespace TextProcessing
{
    public static class Program
    {
        private static string[] ForewordArray;
Run Code Online (Sandbox Code Playgroud)

然后在 Main 中,我初始化并填充数组:

        public static void Main(string[] args)
        {
            try
            {
                try
                {
                    //snip - XML source is opened - snip
                    foreword = XMLnav.SelectSingleNode("//iso:foreword", NSmgr);
                    forewordText = foreword.InnerXml;
                    ForewordTextP = (forewordText.Length - forewordText.Replace("<p", string.Empty).Length) / 2 + 1;
                    CurrFPos = 1;
                    LastFPos = 1;
                    string[] ForewordArray = new string[ForewordTextP];
                    for (var z = 0; z <= ForewordTextP - 1; z++)
                    {
                        LastFPos = CurrFPos;
                        if …
Run Code Online (Sandbox Code Playgroud)

c#

-1
推荐指数
1
解决办法
91
查看次数

标签 统计

c# ×1