public string zxlu,lxlr,sjbs,xxcx,rzck,xxts;string a='1,2,5'如何循环赋值:zxlu="-"  lxlr="-"  rzck="-" 其它为:sjbs="."  xxcx="." xxts="."  

解决方案 »

  1.   

    What do you want to do?
      

  2.   

    zxlu=lxlr=rzck="-".
    sjbs=xxcx=xxts=".". lz要怎么循环?  
      

  3.   

    问题是这样的啊.
    public string zxlu,lxlr,sjbs,xxcx,rzck,xxts;string a='1,2,5'
    zxlu 对应 1   如果有对应关系 zxlu="-"  
    lxlr 对应 2   .............. lxlr="-"  
    sjbs 对应 3   如果没有对应关系 sjbs="."
    xxcx 对应 4   如果没有对应关系 xxcx="."
    rzck 对应 5   如果有对应关系 rzck="-"  
    xxts 对应 6   如果没有对应关系 xxts="."大家明白没?? 我看大家有没有特别奇特的方法来解决这个循环问题???
      

  4.   

    如果 zxlu,lxlr,sjbs,xxcx,rzck,xxts 这些是固定的就这么几个,不用循环了,好像也没有什么可循环的,循环是要有条件的
      

  5.   

    楼上的,我的string a='1,2,5' 可是个变化的值啊.我不知道它下次是多少啊??不循环咋整??
      

  6.   

    string a='1,2,5'   变化有规律吗,比如递增还是递减,步长多少
      

  7.   

    string a='1,2,5' 下次可能是:
    string a='1,3,5'
    ..
    string a='6,2,5'没啥规律,但和zxlu,lxlr,sjbs,xxcx,rzck,xxts 有对应关系....所以要用循环,我现在处理方法比较土IndexOf("6",0)>=0 表示这个变量中含"6" ,那么 xxts="-" 判断了6次.我看有没有比较简单的方式处理这个问题...谢谢楼上的.
      

  8.   

    不说别的,这句:
    string a='1,2,5'
    能编译通过吗.......
      

  9.   

    好像是指 a 中含有指定字符,则zxlu="-"  lxlr="-"  rzck="-" 
    否则sjbs="."  xxcx="." xxts="."  
    a中字符可能取值为(1-6)中的任3个.不知道LZ目的是什么?
      

  10.   

    zxlu="-"  lxlr="-"  rzck="-" 
    sjbs="."  xxcx="." xxts="."  
    应该定义为一个数组!!
      

  11.   

    回复人:iloveyoujia(每天一个故事) ( ) 信誉:100 2007-01-07 10:54:47 得分:0
    ? string a='1,2,5';
    ---------------------------
    我指的不是你没加分号......
    这是加了分号后csc的信息:
    error CS1012: 字符文本中的字符太多
      

  12.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using System.IO;
    namespace Con070107
    {
        class Program
        {
            static void Main(string[] args)
            {
                string a = "1,2,5";//a可以变化;
               String [] aa=new string[6];
    /*zxlu="-"  lxlr="-"  rzck="-" 
    sjbs="."  xxcx="." xxts="."  
    应该定义为一个数组!!  */for(int i=1 ;i<=6;i++)
    {
        if (a.IndexOf(i.ToString()) >=0)
            aa[i-1] = "-";
        else
            aa[i-1] = ".";
    }
    for (int i = 0; i <= 5; i++)
    {
        System.Console.WriteLine(aa[i]);
    }
            }
        }
    }
    以上已测试通过!!}
      

  13.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using System.IO;
    namespace Con070107
    {
        class Program
        {
            static void Main(string[] args)
            {
                string a = "1,2,5";//a可以变化;
               String [] aa=new string[6];
    /*zxlu="-"  lxlr="-"  rzck="-" 
    sjbs="."  xxcx="." xxts="."  
    应该定义为一个数组!!  */for(int i=1 ;i<=6;i++)
    {
        if (a.IndexOf(i.ToString()) >=0)
            aa[i-1] = "-";
        else
            aa[i-1] = ".";
    }
    for (int i = 0; i <= 5; i++)
    {
        System.Console.WriteLine(aa[i]);
    }
            }
        }
    }}
    以上已测试通过!!
      

  14.   

    问题给你解决了,帮我顶一下这个贴:
    http://community.csdn.net/Expert/topic/5277/5277704.xml
    http://community.csdn.net/Expert/topic/5277/5277704.xml?temp=.7580377
      

  15.   

    再加上:
    zxlu=aa[0];  lxlr=aa[1];  rzck=aa[2] 
    sjbs=aa[3];  xxcx=aa[4]; xxts=aa[5];就OK!!
      

  16.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using System.IO;
    namespace Con070107
    {
        class Program
        {
            static void Main(string[] args)
            {
                string a = "1,2,5";//a可以变化;
               String [] aa=new string[6];
    /*zxlu="-"  lxlr="-"  rzck="-" 
    sjbs="."  xxcx="." xxts="."  
    应该定义为一个数组!!  */for(int i=1 ;i<=6;i++)
    {
        if (a.IndexOf(i.ToString()) >=0)
            aa[i-1] = "-";
        else
            aa[i-1] = ".";
    }
    /* for (int i = 0; i <= 5; i++)
    {
        System.Console.WriteLine(aa[i]);
    }  */
    zxlu=aa[0];  lxlr=aa[1];  rzck=aa[2] 
    sjbs=aa[3];  xxcx=aa[4]; xxts=aa[5];        }
        }
    }}
    以上已测试通过!!
      

  17.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using System.IO;
    namespace Con070107
    {
        class Program
        {
            static void Main(string[] args)
            {
                string a = "1,2,5";//a可以变化;
               String [] aa=new string[6];
    /*zxlu="-"  lxlr="-"  rzck="-" 
    sjbs="."  xxcx="." xxts="."  
    应该定义为一个数组!!  */for(int i=1 ;i<=6;i++)
    {
        if (a.IndexOf(i.ToString()) >=0)
            aa[i-1] = "-";
        else
            aa[i-1] = ".";
    }
    /* for (int i = 0; i <= 5; i++)
    {
        System.Console.WriteLine(aa[i]);
    }  */
    zxlu=aa[0];  lxlr=aa[1];  rzck=aa[2] ;
    sjbs=aa[3];  xxcx=aa[4]; xxts=aa[5];        }
        }
    }}
    以上已测试通过!!