當前位置: 首頁>>代碼示例>>C#>>正文


C# System.String類代碼示例

本文整理匯總了C#中System.String的典型用法代碼示例。如果您正苦於以下問題:C# String類的具體用法?C# String怎麽用?C# String使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


String類屬於System命名空間,在下文中一共展示了String類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: return

 public BaseValidator this[String id]
 {
     get
     {
         return ((List<BaseValidator>) validators).Find(validator => validator.Id == id);
     }
 }
開發者ID:lucaslra,項目名稱:SPM,代碼行數:7,代碼來源:ValidatorCollection.cs

示例2: LoadEvents

        private static Dictionary<DateTime, String> LoadEvents(String filePath)
        {
            List<String> activities = new List<String>();
            List<DateTime> timestamps = new List<DateTime>();

            Dictionary<DateTime, String> events = new Dictionary<DateTime, String>();

            int k = 0;
            foreach (String line in File.ReadAllLines(filePath))
            {
                string[] tokens = line.Split(new char[] { ';' });
                Console.WriteLine("Line " + k);
                timestamps.Add(DateTime.Parse(tokens[0]));
                activities.Add(tokens[1]);
                events.Add(DateTime.Parse(tokens[0]), tokens[1]);
                Console.WriteLine("Timestamp per line " + DateTime.Parse(tokens[0]) + " Activity = " + tokens[1]);
                k++;

            }
            var tsArray = timestamps.ToArray();
            var actArray = activities.ToArray();
            Console.WriteLine("tsArray length " + tsArray.Length + ", actArray length " + actArray.Length);
            for (int j = 0; j < tsArray.Length; j++)
            {
                Console.WriteLine("tsArray[" + j + "] = " + tsArray[j].ToString() + " -- actArray[" + j + "] = " + actArray[j].ToString());
            }

            SimulateReadingFile(events);

            return events;
        }
開發者ID:imanhelal,項目名稱:RuntimeDeductionCaseID,代碼行數:31,代碼來源:Program.cs

示例3: GetField

	public override FieldInfo GetField(String name, int lexlevel)
			{
				return GetField(name, BindingFlags.Instance |
									  BindingFlags.Static |
									  BindingFlags.Public |
									  BindingFlags.DeclaredOnly);
			}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:7,代碼來源:GlobalScope.cs

示例4: BuscarClienteD

        //-----------------------------------

        public List<Cliente> BuscarClienteD(String apellido, String nombre, String mail, Decimal documento)
        {
            var query = String.Format(@"Select * FROM LA_REVANCHA.CLIENTE WHERE 1 = 1 ");

            if (apellido != "")
            {
                query = query + "AND CLI_APELLIDO = '" + apellido + "' ";
            }
            if (nombre != "")
            {
                query = query + "AND CLI_NOMBRE = '" + nombre + "' ";
            }
            if (documento != 0)
            {
                query = query + "AND CLI_NUMERO_IDENTIFICACION = " + documento;
            }
            if (mail != "")
            {
                query = query + "AND CLI_MAIL = '" + mail + "' ";
            }

            DataRowCollection dataRow = SQLUtils.EjecutarConsultaSimple(query, "LA_REVANCHA.CLIENTE");

                var clientes = dataRow.ToList<Cliente>(this.DataRowToCliente);
                return clientes;
            
        }
開發者ID:cthaeh,項目名稱:NINIRODIE-HOTEL,代碼行數:29,代碼來源:RepositorioCliente.cs

示例5: Initialise

 public void Initialise(IConfigSource config)
 {
     try 
     {
         m_config = config.Configs["SimianGrid"];
        
         if (m_config != null)
         {
             m_simianURL = m_config.GetString("SimianServiceURL");
             if (String.IsNullOrEmpty(m_simianURL))
             {
                 // m_log.DebugFormat("[SimianGrid] service URL is not defined");
                 return;
             }
             
             InitialiseSimCap();
             SimulatorCapability = SimulatorCapability.Trim();
             m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability);
         }
     }
     catch (Exception e)
     {
         m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message);
         return;
     }
 }
開發者ID:ffoliveira,項目名稱:opensimulator,代碼行數:26,代碼來源:SimianGrid.cs

示例6: SetupAutoCADIOContainer

        /// <summary>
        /// Does setup of AutoCAD IO. 
        /// This method will need to be invoked once before any other methods of this
        /// utility class can be invoked.
        /// </summary>
        /// <param name="autocadioclientid">AutoCAD IO Client ID - can be obtained from developer.autodesk.com</param>
        /// <param name="autocadioclientsecret">AutoCAD IO Client Secret - can be obtained from developer.autodesk.com</param>
        public static void SetupAutoCADIOContainer(String autocadioclientid, String autocadioclientsecret)
        {
            try
            {
                String clientId = autocadioclientid;
                String clientSecret = autocadioclientsecret;

                Uri uri = new Uri("https://developer.api.autodesk.com/autocad.io/us-east/v2/");
                container = new AIO.Operations.Container(uri);
                container.Format.UseJson();

                using (var client = new HttpClient())
                {
                    var values = new List<KeyValuePair<string, string>>();
                    values.Add(new KeyValuePair<string, string>("client_id", clientId));
                    values.Add(new KeyValuePair<string, string>("client_secret", clientSecret));
                    values.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
                    var requestContent = new FormUrlEncodedContent(values);
                    var response = client.PostAsync("https://developer.api.autodesk.com/authentication/v1/authenticate", requestContent).Result;
                    var responseContent = response.Content.ReadAsStringAsync().Result;
                    var resValues = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseContent);
                    _accessToken = resValues["token_type"] + " " + resValues["access_token"];
                    if (!string.IsNullOrEmpty(_accessToken))
                    {
                        container.SendingRequest2 += (sender, e) => e.RequestMessage.SetHeader("Authorization", _accessToken);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(String.Format("Error while connecting to https://developer.api.autodesk.com/autocad.io/v2/", ex.Message));
                container = null;
                throw;
            }
        }
開發者ID:CADblokeCADforks,項目名稱:library-dotnet-autocad.io,代碼行數:42,代碼來源:AutoCADIOUtilities.cs

示例7: RepositoryFile

		public RepositoryFile(IRepository repository, String path, RepositoryStatus contentsStatus, RepositoryStatus propertiesStatus)
		{
			if (path == null)
				throw new ArgumentNullException("path");
			if (path.Trim().Length == 0)
				throw new ArgumentException("Path must be set to a valid path", "path");
			if (path[path.Length-1] == '/')
				throw new ArgumentException("Path must be set to a file, not a directory", "path");
			if (propertiesStatus == RepositoryStatus.Added ||
				propertiesStatus == RepositoryStatus.Deleted)
			{
				throw new ArgumentException("Properties status cannot be set to Added or Deleted, use Updated", "propertiesStatus");
			}
			
			this.contentsStatus = contentsStatus;
			this.propertiesStatus = propertiesStatus;
			this.repository = repository;
			SetPathRelatedFields(path);

			if (fileName.EndsWith(" "))
				throw new ArgumentException("Filename cannot end with trailing spaces", "path");

			if (fileName.StartsWith(" "))
				throw new ArgumentException("Filename cannot begin with leading spaces", "path");

		}
開發者ID:atczyc,項目名稱:castle,代碼行數:26,代碼來源:RepositoryFile.cs

示例8: CUser

		public CUser(String[] ConnectInfo,DataRow dr) : base(ConnectInfo)
		{
			
			//根據數據行設置用戶的屬性
			SetUserProperty(dr);

		}
開發者ID:jquery2005,項目名稱:GMIS,代碼行數:7,代碼來源:CUser.cs

示例9: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     IUnityContainer container = new UnityContainer();
     UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
     section.Configure(container);
     if (Request["installation"] != null)
     {
         int installationid = Int32.Parse(Request["installation"]);
         userid = Int32.Parse(Request["userid"]);
         user = Request["user"];
         sservice = container.Resolve<IStatisticService>();
         IInstallationBL iinstall = container.Resolve<IInstallationBL>();
         imodel = iinstall.getInstallation(installationid);
         Dictionary<InstallationModel, List<InstallationState>> statelist = sservice.getInstallationState(imodel.customerid);
         StringBuilder str = new StringBuilder();
         str.Append("<table border = '1'><tr><th>Description</th><th>Messwert</th><th>Einheit</th></tr>");
         foreach (var values in statelist)
         {
             if(values.Key.installationid.Equals(installationid))
             {
                 foreach (var item in values.Value)
                 {
                      str.Append("<tr><td>" + item.description + "</td><td>" + item.lastValue + "</td><td>" + item.unit + "</td></tr>");
                 }
                 break;
             }
         }
         str.Append("</table>");
         anlagenzustand.InnerHtml = str.ToString();
     }
 }
開發者ID:daniel9992000,項目名稱:bif5-sks-csharp,代碼行數:31,代碼來源:InstallationDetail.aspx.cs

示例10: Decrypt

        public String Decrypt(String input)
        {
            String decryptedDataString = null;
            try
            {
                // Derive a key from the password.
                IBuffer derivedKeyBuffer = DeriveKeyFromPassword();

                // Convert the initialization vector string to binary.
                IBuffer ivBuffer = CryptographicBuffer.ConvertStringToBinary(ivString, BinaryStringEncoding.Utf8);

                // Decrypt the input.
                IBuffer decryptedDataBuffer = DecryptDataBuffer(derivedKeyBuffer, input, cipherAlgName, ivBuffer);
                if (decryptedDataBuffer == null)
                {
                    return null;
                }
                decryptedDataString = CryptographicBuffer.ConvertBinaryToString(Windows.Security.Cryptography.BinaryStringEncoding.Utf8, decryptedDataBuffer);
            }
            catch (Exception e)
            {
                // Ignroe errors;
            }
            return decryptedDataString;
        }
開發者ID:bennettp123,項目名稱:NodeUsageMeter,代碼行數:25,代碼來源:CredentialsEncrypter.cs

示例11: Read

        public void Read(ByteArray bs)
        {
            signature = bs.ReadStringNull();
            streamVersion = bs.ReadInt();
            unityVersion = bs.ReadStringNull();
            unityRevision = bs.ReadStringNull();
            minimumStreamedBytes = bs.ReadInt();
            headerSize = bs.ReadUInt();

            numberOfLevelsToDownload = bs.ReadInt();
            int numberOfLevels = bs.ReadInt();

            for (int i = 0; i < numberOfLevels; i++)
            {
                levelByteEnd.Add(new LevelInfo() { PackSize = bs.ReadUInt(), UncompressedSize = bs.ReadUInt() });
            }

            if (streamVersion >= 2)
            {
                completeFileSize = bs.ReadUInt();
            }

            if (streamVersion >= 3)
            {
                dataHeaderSize = bs.ReadUInt();
            }

            bs.ReadByte();
        }
開發者ID:hexiaoweiff8,項目名稱:AssetBundleReader,代碼行數:29,代碼來源:AssetBundleHeader.cs

示例12: CollaboratingWorkbooksEnvironment

 private CollaboratingWorkbooksEnvironment(String[] workbookNames, WorkbookEvaluator[] evaluators, int nItems)
 {
     Hashtable m = new Hashtable(nItems * 3 / 2);
     Hashtable uniqueEvals = new Hashtable(nItems * 3 / 2);
     for (int i = 0; i < nItems; i++)
     {
         String wbName = workbookNames[i];
         WorkbookEvaluator wbEval = evaluators[i];
         if (m.ContainsKey(wbName))
         {
             throw new ArgumentException("Duplicate workbook name '" + wbName + "'");
         }
         if (uniqueEvals.ContainsKey(wbEval))
         {
             String msg = "Attempted To register same workbook under names '"
                 + uniqueEvals[(wbEval) + "' and '" + wbName + "'"];
             throw new ArgumentException(msg);
         }
         uniqueEvals[wbEval]=wbName;
         m[wbName] = wbEval;
     }
     UnhookOldEnvironments(evaluators);
     //HookNewEnvironment(evaluators, this); - moved to Setup method above
     _unhooked = false;
     _evaluators = evaluators;
     _evaluatorsByName = m;
 }
開發者ID:missxiaohuang,項目名稱:Weekly,代碼行數:27,代碼來源:CollaboratingWorkbooksEnvironment.cs

示例13: _addRptParams

 private static void _addRptParams(IDbConnection conn, String rptUID, Params prms, String userUID, String remoteIP) {
   var v_prms = new Params();
   v_prms.SetValue("p_rpt_uid", rptUID);
   var v_sql = "begin xlr.clear_rparams(:p_rpt_uid); end;";
   SQLCmd.ExecuteScript(conn, v_sql, v_prms, 120);
   v_sql = "begin xlr.add_rparam(:p_rpt_uid, :p_prm_name, :p_prm_type, :p_prm_val, :p_usr_uid, :p_remote_ip); end;";
   foreach (var v_prm in prms) {
     v_prms.SetValue("p_prm_name", v_prm.Name);
     String v_prmValue;
     var v_prmTypeStr = "A";
     if (v_prm.Value != null) {
       var v_prmType = v_prm.ParamType ?? v_prm.Value.GetType();
       if (Utl.TypeIsNumeric(v_prmType)) {
         v_prmTypeStr = "N";
         v_prmValue = "" + v_prm.Value;
         v_prmValue = v_prmValue.Replace(",", ".");
       } else if (v_prmType == typeof(DateTime)) {
         v_prmTypeStr = "D";
         v_prmValue = ((DateTime)v_prm.Value).ToString("yyyy.MM.dd HH:mm:ss");
       } else
         v_prmValue = "" + v_prm.Value;
     } else
       continue;
     v_prms.SetValue("p_prm_type", v_prmTypeStr);
     v_prms.SetValue("p_prm_val", v_prmValue);
     v_prms.SetValue("p_usr_uid", userUID);
     v_prms.SetValue("p_remote_ip", remoteIP);
     SQLCmd.ExecuteScript(conn, v_sql, v_prms, 120);
   }
 }
開發者ID:tormoz70,項目名稱:Bio.Framework.8,代碼行數:30,代碼來源:CQueueDefaultImpl.cs

示例14: initLabels

 private void initLabels()
 {
     PersianDate pd = new PersianDate(DateTime.Today);
     date_Lbl.Content = pd.ToShortDateString();
     newId = getNewId();
     ID_Lbl.Content = Codes.ApartmanMaskooniForooshi + " -  " + newId;
 }
開發者ID:omid55,項目名稱:real_state_manager,代碼行數:7,代碼來源:ApartmanMaskooniF.xaml.cs

示例15: RunProgam

		static public bool RunProgam(String asFile, String asArgs)
		{
			Process myProcess = new Process();
            
			try
			{
				myProcess.StartInfo.FileName = asFile; 
				myProcess.StartInfo.Arguments = asArgs;
				myProcess.Start();
			}
			catch (Win32Exception e)
			{
				if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
				{
					return false;
				} 

				else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
				{
					return false;
				}
			}

			return true;
		}
開發者ID:whztt07,項目名稱:HPL1Engine,代碼行數:25,代碼來源:ParticleSystem.cs


注:本文中的System.String類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。