2024年5月23日 星期四

Array 新增值 *.js *.cs - - c# 判斷字串是否在長字串內

 目的: Array 新增值 - 判斷值是否在Array

處理說明:  1> *.js  , js  Array 才有 push method
                        var   PK_LIST: [], //儲存 PK欄位.欄位值
                        PK_LIST.push(Tmp_PK);

                        if  (PK_LIST.indexOf(Tmp_PK)== -1){}

                   2>*.cs , cs Arrary 無 puch method , 必需先增加Array長度, 再 Assign 欄位值
                         再 Assign  Tmp_Ary[i] = Tmp_Str
                          string[] Tmp_RPNOAF_Ary = new string[] {};      
                          Array.Resize(ref Tmp_RPNOAF_Ary, Tmp_RPNOAF_Ary.Length + 1);
                         Tmp_RPNOAF_Ary[Tmp_RPNOAF_Ary.Length - 1] = Tmp_RPNOAF;

                         if (Array.IndexOf(Tmp_RPNOAF_Ary,Tmp_RPNOAF) ==-1)  {}
                         if ("1;2;3;4;5;6;7;8;".IndexOf(Tmp_IRESAK) == -1)  {}
                     
                  3>c# 字串判斷是否存在 , 若 Tmp_IRESAK 為"", 則傳回 0 , 非 -1
                        if ("1;2;3;4;5;6;7;8;".IndexOf(Tmp_IRESAK) == -1)
                            {
                                Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[檢測結果代碼]欄位值不符!!"
                                                          +"(" +Tmp_IRESAK + ")<br>";
                            }
                        --> 所以必需先判斷 Tmp_IRESAK 是否為空字串
                               if (myfunc.checkisnull(Tmp_IRESAK.Trim()))
                                {
                                  Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[檢測結果代碼]欄位值不可空白!!<br>";
                                  }  


1>*.cs  string.IndexOf   &  Array.IndexOf(Tmp_Ary,Tmp_Str) 
if (Array.IndexOf(Tmp_RPNOAF_Ary,Tmp_RPNOAF) ==-1)  {}
if ("1;2;3;4;5;6;7;8;".IndexOf(Tmp_IRESAK) ==-1)  {}


 if (myfunc.checkisnull(Tmp_IRESAK.Trim()))
{
     Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[檢測結果代碼]欄位值不可空白!!<br>";
}
else
{
  if ("1;2;3;4;5;6;7;8;".IndexOf(Tmp_IRESAK) == -1)
  {
  Tmp_RtnMsg1 = Tmp_RtnMsg1 + "[檢測結果代碼]欄位值不符!!(" + Tmp_IRESAK + ")<br>";
   }
}                        

沒有留言:

張貼留言