本文整理汇总了C#中System.String.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# String.SetValue方法的具体用法?C# String.SetValue怎么用?C# String.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToArray
public String[] ToArray()
{
String[] hiddenPaths = new String[List.Count];
for (Int32 i = 0; i < List.Count; i++)
{
hiddenPaths.SetValue(List[i], i);
}
return hiddenPaths;
}
示例2: GetStringsProperties
/// <summary>
/// получить список названий properties
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static String[] GetStringsProperties(Type type)
{
IList<PropertyInfo> listP = type.GetProperties();
String[] listS = new String[listP.Count];
foreach (PropertyInfo infoProperty in listP)
listS.SetValue(infoProperty.Name, listP.IndexOf(infoProperty));
Array.Sort(listS);
return listS;
}
示例3: GetReplacement
private static bool GetReplacement(String[] badwords, String[] filterwords, ref string find, ref string replacement)
{
if (find == "")
{
return false;
}
if (filterwords.Length == 2)
{
for (int m = 0; m < badwords.Length; m++)
{
if (filterwords[1].ToString() != "")
{
replacement = filterwords[1].ToString();
}
}
}
else if (filterwords.Length < 2)
{
for (int m = 0; m < badwords.Length; m++)
{
replacement = "**";
}
}
else
{
replacement = filterwords[filterwords.Length - 1];
filterwords.SetValue("", filterwords.Length - 1);
find = string.Join("=", filterwords);
find = find.Remove(find.Length - 2);
}
if (replacement == string.Empty)
{
replacement = "**";
}
return true;
}
示例4: PopulateDados
public bool PopulateDados(List<ACCC033.ContratoParcelaACCC033> listCon)
{
bool ret = false;
try
{
using (OracleConnection connection = new OracleConnection(RetornoCIP.CNX_C3))
{
String[] arrNU_CON = new String[listCon.Count];
String[] arrTP_EVT = new String[listCon.Count];
String[] arrSIT_EVT = new String[listCon.Count];
String[] arrNU_PAR = new String[listCon.Count];
String[] arrCODERR = new String[listCon.Count];
for (int i = 0; i < listCon.Count; i++)
{
arrNU_CON.SetValue(listCon[i].NU_CON, i);
arrTP_EVT.SetValue(listCon[i].TpMotvEvt, i);
arrSIT_EVT.SetValue(listCon[i].SitEvt, i);
arrNU_PAR.SetValue(listCon[i].NU_PAR, i);
arrCODERR.SetValue(listCon[i].CodErro, i);
}
OracleCommand command = new OracleCommand(@"insert into CCCTBL033 (NU_CONTRATO, TIPMOTVEVT, SITEVT, NU_PARCELA, CODERR)
values (:VER_CON_NU, :TP_EVT, :SIT_EVT, :VER_PAR_NU, :CODERR)", connection);
command.CommandType = CommandType.Text;
command.ArrayBindCount = listCon.Count;
// VER_CON_NU parameter
OracleParameter prmNUC = new OracleParameter("VER_CON_NU", OracleDbType.Varchar2);
prmNUC.Direction = System.Data.ParameterDirection.Input;
prmNUC.Value = arrNU_CON;
command.Parameters.Add(prmNUC);
// TP_EVT parameter
OracleParameter prmTPE = new OracleParameter("TP_EVT", OracleDbType.Varchar2);
prmTPE.Direction = System.Data.ParameterDirection.Input;
prmTPE.Value = arrTP_EVT;
command.Parameters.Add(prmTPE);
// SIT_EVT parameter
OracleParameter prmSIE = new OracleParameter("SIT_EVT", OracleDbType.Varchar2);
prmSIE.Direction = System.Data.ParameterDirection.Input;
prmSIE.Value = arrSIT_EVT;
command.Parameters.Add(prmSIE);
// VER_PAR_NU parameter
OracleParameter prmNUP = new OracleParameter("VER_PAR_NU", OracleDbType.Varchar2);
prmNUP.Direction = System.Data.ParameterDirection.Input;
prmNUP.Value = arrNU_PAR;
command.Parameters.Add(prmNUP);
// CODERR parameter
OracleParameter prmErr = new OracleParameter("CODERR", OracleDbType.Varchar2);
prmErr.Direction = System.Data.ParameterDirection.Input;
prmErr.Value = arrCODERR;
command.Parameters.Add(prmErr);
connection.Open();
command.ExecuteNonQuery();
if (Utils._logger != null)
Utils._logger.Info(command.ArrayBindCount + " registros inseridos");
connection.Close();
ret = true;
}
}
catch (Exception ex)
{
if (Utils._logger != null)
Utils._logger.Error(ex.Message);
}
return ret;
}
示例5: ParseJoins
/// <summary>
/// Parse Joins and return new script
/// </summary>
public String[] ParseJoins(String Script)
{
MatchCollection col = Regex.Matches(Script, "join\\(\"(?<class>[A-Za-z0-9]*)\"\\);", RegexOptions.IgnoreCase);
String NewScript = Regex.Replace(Script, "join\\(\"(?<class>[A-Za-z0-9]*)\"\\);", "", RegexOptions.IgnoreCase);
String Serverside, Clientside;
foreach (Match x in col)
{
ServerClass Class = this.FindClass(x.Groups["class"].Value);
if (Class != null)
NewScript += "\n" + Class.Script;
}
int pos = NewScript.IndexOf("//#CLIENTSIDE");
if (pos >= 0)
{
Serverside = NewScript.Substring(0, pos);
Clientside = NewScript.Substring(pos + 13);
}
else
{
Serverside = NewScript;
Clientside = "";
}
//Console.WriteLine(NewScript);
NewScript = Regex.Replace(NewScript, "function\\s*([a-z0-9]+)\\s*\\((.*)\\)(\t|\r|\\s)*\\{(.*)\\}", delegate(Match match)
{
string v = match.ToString();
return char.ToUpper(v[0]) + v.Substring(1);//"public void $1 ($2)\n{\n}\n"
}, RegexOptions.IgnoreCase);
//Console.WriteLine("after regexp: " + NewScript);
String[] scripts = new String[2];
scripts.SetValue(Serverside, 0);
scripts.SetValue(Clientside, 1);
return scripts;
}
示例6: LoadFilters
/// <summary>
/// Load filters to find in event log
/// </summary>
/// <param name="node">specific XML including filter parameters</param>
static void LoadFilters(XmlNode node)
{
String patternSyslogLevel = "Emergency|Alert|Critical|Error|Warning|Notice|Informational|Debug";
Regex rSyslogLevel = new Regex(patternSyslogLevel, RegexOptions.IgnoreCase);
String patternSyslogFacility = "Kern|User|Mail|Daemon|Auth|Syslog|LPR|News|UUCP|Cron|AuthPriv|FTP|NTP|Audit|Audit2|CRON2|Local0|Local1|Local2|Local3|Local4|Local5|Local6|Local7";
Regex rSyslogFacility = new Regex(patternSyslogFacility, RegexOptions.IgnoreCase);
String[] eventLogName = null;
Filter iFilter = null;
Filter eFilter = null;
foreach (XmlNode childnode in node.ChildNodes)
{
eventLogName = null;
iFilter = new Filter();
eFilter = new Filter();
foreach (XmlNode cnode in childnode.ChildNodes)
{
if (cnode.Name.ToLower().CompareTo("event") == 0)
{
foreach (XmlNode paramNode in cnode.ChildNodes)
{
if (paramNode.Name.ToLower().CompareTo("eventlogname") == 0)
{
ArrayList temp = new ArrayList();
foreach (XmlNode element in paramNode.ChildNodes)
{
if (element.Name.IndexOf("#comment") < 0)
{
temp.Add(element.InnerText);
}
}
eventLogName = new String[temp.Count];
int i = 0;
foreach (String item in temp)
{
eventLogName.SetValue(item, i);
i++;
}
}
else if (paramNode.Name.ToLower().CompareTo("sources") == 0)
{
ArrayList itemp = new ArrayList();
ArrayList etemp = new ArrayList();
foreach (XmlNode element in paramNode.ChildNodes)
{
if (element.Name.IndexOf("include") >= 0)
{
itemp.Add(element.InnerText);
}
else if (element.Name.IndexOf("exclude") >= 0)
{
etemp.Add(element.InnerText);
}
}
if (itemp.Count > 0)
{
String[] strTemp = new String[itemp.Count];
int i = 0;
foreach (String item in itemp)
{
strTemp.SetValue(item, i);
i++;
}
iFilter.EventLogSources = strTemp;
}
if (etemp.Count > 0)
{
String[] strTemp = new String[etemp.Count];
int i = 0;
foreach (String item in etemp)
{
strTemp.SetValue(item, i);
i++;
}
eFilter.EventLogSources = strTemp;
}
}
else if (paramNode.Name.ToLower().CompareTo("id") == 0)
{
ArrayList itemp = new ArrayList();
ArrayList etemp = new ArrayList();
foreach (XmlNode element in paramNode.ChildNodes)
{
if (element.Name.IndexOf("include") >= 0)
{
itemp.Add(element.InnerText);
}
else if (element.Name.IndexOf("exclude") >= 0)
{
etemp.Add(element.InnerText);
//.........这里部分代码省略.........
示例7: PrepareToSolve
private static Tuple<String[, ], List<Tuple<int, int>>> PrepareToSolve()
{
String[,] tableToSolve = new String[Program.TABLEWIDTH, Program.TABLEHEIGHT];
List<Tuple<int, int>> fixedPositions = new List<Tuple<int, int>>(0);
for (int i = 0; i < Program.TABLEWIDTH; i++)
for (int j = 0; j < Program.TABLEHEIGHT; j++)
{
if (cells[i, j].Text != String.Empty)
{
fixedPositions.Add(new Tuple<int, int>(i, j));
}
tableToSolve.SetValue(cells[i, j].Text, i, j);
}
fixedPositions.TrimExcess();
return new Tuple<string[,], List<Tuple<int, int>>>(tableToSolve, fixedPositions);
}
示例8: DownloadFiles
//Utilizes WebHDFS API to download files from HDFS, writing to the root directory specified in the command line arguments
private static void DownloadFiles(string basePath, string localPath)
{
try
{
using (var client = new WebClient())
{
//Get the result of the WebHDFS call
string result = client.DownloadString(basePath + listArgs);
JObject o = JObject.Parse(result);
int dirCount = o["FileStatuses"]["FileStatus"].Count();
if (dirCount > 0)
{
//for each directory, list the type, suffix, and size of the file
for (int i = 0; i < dirCount; i++)
{
string dirType = (string)o["FileStatuses"]["FileStatus"][i]["type"];
string pathSuffix = (string)o["FileStatuses"]["FileStatus"][i]["pathSuffix"];
string fileSize = (string)o["FileStatuses"]["FileStatus"][i]["length"];
string newBasePath = null;
string newLocalPath = null;
if (basePath.EndsWith("/"))
{
newBasePath = basePath + pathSuffix;
newLocalPath = localPath + pathSuffix;
}
else
{
newBasePath = basePath + "/" + pathSuffix;
newLocalPath = localPath + "\\" + pathSuffix;
}
//if current file status is a file, download the file
if (dirType.Equals("FILE"))
{
String[] fileProperties = new String[6];
DateTime fileStart = DateTime.UtcNow;
string downloadString = newBasePath + openArgs;
Directory.CreateDirectory(localPath);
Console.WriteLine("Downloading file {0}\nDounload started: {1}", newBasePath, fileStart);
//download the file to the newly created directory
client.DownloadFile(downloadString, newLocalPath);
var fileEnd = DateTime.UtcNow;
var fileDuration = fileEnd - fileStart;
//add file properties to an array for output logs/logging to sql server
fileProperties.SetValue(DateTime.UtcNow.ToShortDateString(), 0);
fileProperties.SetValue(basePath.Replace(baseURL, ""), 1);
fileProperties.SetValue(pathSuffix, 2);
fileProperties.SetValue(fileStart.ToString(), 3);
fileProperties.SetValue(fileEnd.ToString(), 4);
fileProperties.SetValue(fileSize, 5);
Console.WriteLine("Download ended: {0}\nDuration: {1}\n\n", fileProperties[4], fileDuration);
string fileLog = null;
for (int index = 0; index < fileProperties.Length; index++)
{
if (index == fileProperties.Length - 1)
{
fileLog += fileProperties[index] + "\n\r";
}
else
{
fileLog += fileProperties[index] + "|";
}
}
logFileOutput.Write(fileLog);
logFileOutput.Flush();
Console.WriteLine("Uploading file {0}\n\n", newBasePath);
try
{
UploadToBlobAsync(newLocalPath, newBasePath);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
continue;
}
if (logToSql.Equals("true"))
{
LogToDatabase(fileProperties);
}
}
//if current file status is a directory, recursively call DownloadFiles on the sub directory
else if (dirType.Equals("DIRECTORY"))
{
try
{
DownloadFiles(newBasePath, newLocalPath);
}
catch (Exception e)
{
errorWriter.WriteLine("There was an error accessing directory {0}\n\t{1}", newBasePath, e.Message);
errorWriter.Flush();
Console.WriteLine("There was an error accessing directory {0}\n\t{1}", newBasePath, e.Message);
continue;
}
//.........这里部分代码省略.........
示例9: GetWinningCombinationDiagonal
/// <summary>
/// Skilar hornréttri línu úr WinningCombination[][]
/// </summary>
/// <param name="i">i er númer hornréttrar línu ( 1 = 1,5,9 og 2 = 3,5,7 )</param>
/// <returns>
/// Streng sem er 3 á lengd og inniheldur diagonal úr WinningCombination[][]
/// </returns>
public String[] GetWinningCombinationDiagonal(int i)
{
i = i + 6;
var output = new String[3];
for (int j = 0; j < 3; j++)
{
output.SetValue(WinningCombinations[i][j], j);
}
return output;
}
示例10: Join
// --------------------------------------------------------------------------------
/// <summary>
/// Concatenates a specified separator String between each element of a specified
/// String array, yielding a single concatenated string. Parameters specify the
/// first array element and number of elements to use.
/// </summary>
/// <param name="separator">Separator string</param>
/// <param name="value">String vlues to join</param>
/// <param name="startIndex">Index of first element</param>
/// <param name="count">Number of elements to join</param>
/// <returns>Joined value</returns>
// --------------------------------------------------------------------------------
public static DBString Join(DBString separator, DBString [] value, int startIndex, int count)
{
String [] elements = new String [value.GetLength (0)];
int index = 0;
foreach (DBString element in value)
{
elements.SetValue (element, index ++);
}
return String.Join (separator.m_Value, elements, startIndex, count);
}
示例11: Main
static void Main(string[] args)
{
/*
* The object of this program is to ask the user to enter 7 grades for tests
* and then the program will sum those grades and average them.
*/
//Declare and initialize variables
Double dSum = 0.0;
Double dAvg = 0.0;
Double[] dGrades;
String[] sNames;
String sUserResp = String.Empty;
Int32 iStudentCount = 0;
//Determine number of students to have test scores
Console.Write("How many students in the class? ");
sUserResp = Console.ReadLine();
try
{
iStudentCount = Convert.ToInt32(sUserResp);
}
catch(Exception ex)
{
Console.WriteLine("I beg your pardon, fool. You have entered invalid data.");
Console.WriteLine(ex.Message);
Pause("Program will now exit.");
return;
}
dGrades = new Double[iStudentCount];
sNames = new String[iStudentCount];
Type arrayType = dGrades.GetType();
if (arrayType.IsArray)
{
Pause("dGrades is an array of " + arrayType.ToString());
}
else
{
Pause("dGrades is NOT an array.");
}
//Start loop for data entry
for (Int32 i = 0; i < iStudentCount; i++)
{
//Obtain a student name
Console.Write("Enter a name for student #" + (i + 1).ToString() + ": ");
sNames.SetValue(Console.ReadLine(), i);
//Obtain that student's grade
Console.Write("Enter a grade for student #" + (i + 1).ToString() + ": ");
sUserResp = Console.ReadLine();
try
{
dGrades.SetValue(Convert.ToDouble(sUserResp), i);
}
catch (Exception ex)
{
Console.WriteLine("I beg your pardon, fool. You have entered invalid data.");
Console.WriteLine(ex.Message);
Pause("Program will now exit.");
return;
}
//Add this grade to the running sum
dSum += dGrades[i];
}
//Average the grades
dAvg = dSum / (Double)iStudentCount;
Console.WriteLine("\nHere is the breakdown of our student grades:");
for (Int32 i = 0; i < iStudentCount; i++)
{
Console.Write(sNames.GetValue(i) + ": ");
Console.WriteLine(dGrades.GetValue(i).ToString());
}
//Output the average
Pause("The average score is: " + dAvg.ToString() +
".\nProgram will now exit.");
}
示例12: addTextLine
private void addTextLine(String s)
{
String[] temp = null;
temp = new String[richTextBoxInfo.Lines.Length + 1];
richTextBoxInfo.Lines.CopyTo(temp, 0);
temp.SetValue(s, richTextBoxInfo.Lines.Length);
richTextBoxInfo.Lines = temp;
}
示例13: ChooseNum
private Tuple<Solver.Status, string> ChooseNum(int posToChoose_i, int posToChoose_j, String[,] tableToSolve, List<Tuple<int, int>> fixedPositions)
{
List<string> existNums = null;
if (stepsStack.Count > 0)
{
Tuple<Tuple<int, int>, List<string>> lastStep = stepsStack.Peek();
if ((lastStep.Item1.Item1 == posToChoose_i) && (lastStep.Item1.Item2 == posToChoose_j))
{
existNums = lastStep.Item2;
stepsStack.Pop();
}
else
existNums = TableWorker.GetExistentNums(tableToSolve, TABLEWIDTH, TABLEHEIGHT, posToChoose_i, posToChoose_j);
}
else
existNums = TableWorker.GetExistentNums(tableToSolve, TABLEWIDTH, TABLEHEIGHT, posToChoose_i, posToChoose_j);
for (int k = 0; k <= MAXVALUE - 1; k++)
{
string value = TableWorker.CellsValue[k];
if (!existNums.Contains(value))
{
existNums.Add(value);
existNums.TrimExcess();
stepsStack.Push(new Tuple<Tuple<int, int>, List<string>>(
new Tuple<int, int>(posToChoose_i, posToChoose_j), existNums));
return new Tuple<Solver.Status ,string>(Solver.Status.ValueChoosed, value);
}
}
if (stepsStack.Count > 0)
{
tableToSolve.SetValue(String.Empty, posToChoose_i, posToChoose_j);
return new Tuple<Solver.Status ,string>(Solver.Status.stackRollback, String.Empty);
}
else
return new Tuple<Solver.Status ,string>(Solver.Status.Error, String.Empty);
}
示例14: InsertNum
private Solver.Status InsertNum(int start_i, int start_j, String[,] tableToSolve, List<Tuple<int, int>> fixedPositions)
{
bool setStart_i = true;
bool setStart_j = true;
for (int i = 0; i < TABLEWIDTH; i++)
{
if (setStart_i)
if (i != start_i) { continue; }
else setStart_i = false;
for (int j = 0; j < TABLEHEIGHT; j++)
{
if (setStart_j)
if (j != start_j) { continue; ; }
else setStart_j = false;
if (!TableWorker.IsFixed(i, j, fixedPositions))
if ((string)tableToSolve.GetValue(i, j) == String.Empty)
{
Tuple<Solver.Status, string> chooseResult = ChooseNum(i, j, tableToSolve, fixedPositions);
switch (chooseResult.Item1)
{
case (Solver.Status.stackRollback):
return Solver.Status.stackRollback;
case (Solver.Status.Error):
return Solver.Status.Error;
case (Solver.Status.ValueChoosed):
tableToSolve.SetValue(chooseResult.Item2, i, j);
break;
}
}
}
}
return Solver.Status.Solved;
}
示例15: TestSetValue4
public void TestSetValue4() {
{
int[] c1 = { 1, 2, 3 };
long[] c2 = new long [3];
for (int i = 0; i < c1.Length; i++)
c2.SetValue (c1 [i], i);
for (int i = 0; i < c1.Length; i++) {
Assert ("#M81(" + i + ")", c1[i] == c2[i]);
AssertEquals ("#M82(" + i + ")", typeof (long), c2[i].GetType ());
}
}
{
long[] c1 = { 1, 2, 3 };
int[] c2 = new int [3];
bool errorThrown = false;
try {
c2.SetValue (c1 [0], 0);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#M83", errorThrown);
}
{
int[] c1 = { 1, 2, 3 };
Object[] c2 = new Object [3];
for (int i = 0; i < c1.Length; i++)
c2.SetValue (c1 [i], i);
for (int i = 0; i < c1.Length; i++)
AssertEquals ("#M84(" + i + ")", c1[i], Convert.ToInt32 (c2[i]));
}
{
Object[] c1 = new Object [3];
Object[] c2 = new Object [3];
c1[0] = new Object ();
for (int i = 0; i < c1.Length; i++)
c2.SetValue (c1 [i], i);
for (int i = 0; i < c1.Length; i++)
AssertEquals ("#M85(" + i + ")", c1[i], c2[i]);
}
{
Object[] c1 = new Object [3];
string[] c2 = new String [3];
string test = "hello";
c1[0] = test;
c2.SetValue (c1 [0], 0);
AssertEquals ("#M86", c1[0], c2[0]);
AssertEquals ("#M87", "hello", c2[0]);
}
{
char[] c1 = { 'a', 'b', 'c' };
string[] c2 = new string [3];
try {
c2.SetValue (c1 [0], 0);
Fail ("#M88");
} catch (InvalidCastException) {}
}
{
Single[] c1 = { 1.2F, 2.3F, 3.4F, 4.5F };
long[] c2 = new long [3];
try {
c2.SetValue (c1 [0], 0);
Fail ("#M89");
} catch (ArgumentException) {}
}
{
Type[] types = {
typeof (Boolean),
typeof (Byte),
typeof (Char),
typeof (Double),
typeof (Int16),
typeof (Int32),
typeof (Int64),
typeof (SByte),
typeof (Single),
typeof (UInt16),
typeof (UInt32),
typeof (UInt64)
};
bool v1 = true;
Byte v2 = 1;
Char v3 = 'a';
Double v4 = -1.2;
Int16 v5 = -32;
Int32 v6 = -234;
Int64 v7 = -34523;
SByte v8 = -1;
Single v9 = -4.8F;
UInt16 v10 = 24234;
UInt32 v11 = 235354;
UInt64 v12 = 234552;
//.........这里部分代码省略.........