本文整理汇总了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);
}
}
示例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;
}
示例3: GetField
public override FieldInfo GetField(String name, int lexlevel)
{
return GetField(name, BindingFlags.Instance |
BindingFlags.Static |
BindingFlags.Public |
BindingFlags.DeclaredOnly);
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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");
}
示例8: CUser
public CUser(String[] ConnectInfo,DataRow dr) : base(ConnectInfo)
{
//根据数据行设置用户的属性
SetUserProperty(dr);
}
示例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();
}
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例14: initLabels
private void initLabels()
{
PersianDate pd = new PersianDate(DateTime.Today);
date_Lbl.Content = pd.ToShortDateString();
newId = getNewId();
ID_Lbl.Content = Codes.ApartmanMaskooniForooshi + " - " + newId;
}
示例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;
}