本文整理汇总了C#中Tuple.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.ToString方法的具体用法?C# Tuple.ToString怎么用?C# Tuple.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple.ToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Tuple<string, string> name = new Tuple<string, string>("Jochen", "Rindt");
Console.WriteLine(name.ToString());
var result = Divide(5, 2);
Console.WriteLine("result of division: {0}, reminder: {1}", result.Item1, result.Item2);
AnyElementNumber();
}
示例2: Main
static void Main()
{
Tuple<string, string> name = new Tuple<string, string>("Jochen", "Rindt");
WriteLine(name.ToString());
var result = Divide(5, 2);
WriteLine($"result of division: {result.Item1}, remainder: {result.Item2}");
AnyElementNumber();
}
示例3: Sample
public void Sample()
{
// Создание кортежа
var tuple = new Tuple<int, string, bool>(42, "abc", true);
// Доступ к компонентам кортежа:
Assert.That(tuple.Item1, Is.EqualTo(42));
Assert.That(tuple.Item2, Is.EqualTo("abc"));
Assert.That(tuple.Item3, Is.EqualTo(true));
//Переопределенный ToString
Assert.That(tuple.ToString(), Is.EqualTo("(42, abc, True)"));
// Переопределенный Equals сравнивает значения компонент кортежа
var otherTuple = new Tuple<int, string, bool>(42, "abc", true);
Assert.IsTrue(tuple.Equals(otherTuple));
}
示例4: Test1
public void Test1()
{
var tuple = new Tuple<int, string, bool>(42, "abc", true);
// Сокращенная запись с автоматическим выводом типов кортежа:
var tuple2 = Tuple.Create(42, "abc", true);
// Доступ к компонентам кортежа:
Assert.That(tuple.Item1, Is.EqualTo(42));
Assert.That(tuple.Item2, Is.EqualTo("abc"));
Assert.That(tuple.Item3, Is.EqualTo(true));
//Переопределенный ToString
Assert.That(tuple.ToString(), Is.EqualTo("(42, abc, True)"));
// Переопределенный Equals сравнивает значения компонент кортежа
Assert.That(tuple, Is.EqualTo(tuple2));
}
示例5: Main
static void Main(string[] args)
{
Tuple<BigInteger, BigInteger> current = new Tuple<BigInteger, BigInteger>(3, 1), back1 = new Tuple<BigInteger, BigInteger>(2, 1), back2 = new Tuple<BigInteger, BigInteger>(1, 0);
ulong k = 1;
for (ulong i = 2; i <= 100; i++)
{
ulong multiplier;
if (i % 3 == 0)
{
multiplier = (2 * k);
k++;
}
else
{
multiplier = 1;
}
current = new Tuple<BigInteger,BigInteger>(back1.Item1 * multiplier + back2.Item1, multiplier*back1.Item2 + back2.Item2);
back2 = back1;
back1 = current;
Console.WriteLine(current.Item1 + "/" +current.Item2);
}
string digits = current.ToString();
int sum = 0;
for (int i = 0; i < digits.Length; i++)
{
sum += int.Parse(digits[i].ToString());
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("ANSWER => " + sum);
Console.WriteLine("DONE");
Console.Read();
}
示例6: track
public Form track(Dictionary<string, double> angles, Tuple<JointType, JointType> bone, IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints)
{
double warnRange = 3;
double neckLow = 79;
double neckHigh = 170;
if (bone.ToString().Contains("Neck"))
{
if (angles["neckAngle"] < neckLow || angles["neckAngle"] > neckHigh)
{
return Form.Bad;
}
else if (angles["neckAngle"] < neckLow + warnRange || angles["neckAngle"] > neckHigh - warnRange)
{
return Form.Warn;
}
}
double kneeLow = 75;
if (bone.ToString().Contains("KneeLeft"))
{
if (angles["leftKneeAngle"] < kneeLow)
{
return Form.Bad;
}
else if (angles["leftKneeAngle"] < kneeLow + warnRange)
{
return Form.Warn;
}
}
if (bone.ToString().Contains("KneeRight"))
{
if (angles["rightKneeAngle"] < kneeLow)
{
return Form.Bad;
}
else if (angles["rightKneeAngle"] < kneeLow + warnRange)
{
return Form.Warn;
}
}
double spineWarnMultiplier = 10;
double spineLow = 176;
double spineHigh = 179.5;
/*if (bone.ToString().Contains("SpineShoulder"))
{
if (angles["upperBackAngle"] < spineLow || angles["upperBackAngle"] > spineHigh)
{
return Form.Bad;
}
else if (angles["upperBackAngle"] < spineLow + warnRange/spineWarnMultiplier || angles["upperBackAngle"] > spineHigh - warnRange/spineWarnMultiplier)
{
return Form.Warn;
}
}*/
if (bone.ToString().Contains("SpineMid"))
{
if (angles["lowerBackAngle"] < spineLow || angles["lowerBackAngle"] > spineHigh)
{
return Form.Bad;
}
else if (angles["lowerBackAngle"] < spineLow + warnRange/spineWarnMultiplier || angles["lowerBackAngle"] > spineHigh - warnRange/spineWarnMultiplier)
{
return Form.Warn;
}
}
double shoulderLow = 135;
double shoulderHigh = 160;
if ((bone.ToString().Contains("ShoulderRight") && bone.ToString().Contains("SpineShoulder")) || (bone.ToString().Contains("ShoulderLeft") && bone.ToString().Contains("SpineShoulder")))
{
if (angles["shoulderAngle"] < shoulderLow || angles["shoulderAngle"] > shoulderHigh)
{
return Form.Bad;
}
else if (angles["shoulderAngle"] < shoulderLow + warnRange || angles["shoulderAngle"] > shoulderHigh - warnRange)
{
return Form.Warn;
}
}
return Form.Good;
}
示例7: doInsertVote
public void doInsertVote(Tuple<BigInteger, BigInteger> c)
{
SQLiteCommand insertSQL = new SQLiteCommand(
"INSERT INTO Votes (Id, CipherG, CipherM, ElectionID) VALUES (@id,@G,@M,@Eid)", dbConn);
insertSQL.Parameters.AddWithValue("@id", System.Guid.NewGuid());
insertSQL.Parameters.AddWithValue("@G", c.Item1.ToString());
insertSQL.Parameters.AddWithValue("@M", c.Item2.ToString());
insertSQL.Parameters.AddWithValue("@Eid", electionID);
try
{
insertSQL.ExecuteNonQuery();
log("Vote Cast" + c.ToString());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例8: SplitAtEqualCloseBracket
/// <summary>
/// Sucht die zugehörige schließende Klammer
/// </summary>
private static Tuple<string, string> SplitAtEqualCloseBracket(string Input)
{
System.Diagnostics.Debug.IndentLevel++;
System.Diagnostics.Debug.WriteLine("Input: " + Input.ToString());
Tuple<string, string> SP = new Tuple<string, string>();
SP.t1 = "";
SP.t2 = "";
int CurrentBracketLevel = 0;
while (Input.Length > 0)
{
if (Input[0] == ')')
if (CurrentBracketLevel == 0)
{
SP.t2 = Input.Substring(1);
break;
}
else
CurrentBracketLevel--;
else if (Input[0] == '(')
CurrentBracketLevel++;
SP.t1 += Input[0];
Input = Input.Substring(1);
}
System.Diagnostics.Debug.WriteLine("Output: " + SP.ToString());
System.Diagnostics.Debug.IndentLevel--;
return SP;
}
示例9: CanToStringFiveSizedTuplesWithNullsInMiddle
public void CanToStringFiveSizedTuplesWithNullsInMiddle()
{
var tuple1 = new Tuple<string>("1", null, "3",null , "5");
tuple1.ToString().Should().Be("1, , 3, , 5");
}
示例10: CanToStringFiveSizedTuples
public void CanToStringFiveSizedTuples()
{
var tuple1 = new Tuple<string>("1", "2", "3", "4", "5");
tuple1.ToString().Should().Be("1, 2, 3, 4, 5");
}
示例11: ToStringTest
public void ToStringTest ()
{
var t1 = new Tuple<int, object, int, int, int, int, int, Tuple<string, string>> (1, null, 3, 4, 5, 6, 7, new Tuple<string, string> (null, null));
Assert.AreEqual ("(1, , 3, 4, 5, 6, 7, , )", t1.ToString (), "#1");
}
示例12: ReferenceAllTypesInClosedGenericVariablesWithReferences
public void ReferenceAllTypesInClosedGenericVariablesWithReferences()
{
Tuple<IInnerInterface, InnerEventArgs, InnerDelegate> tuple =
new Tuple<IInnerInterface, InnerEventArgs, InnerDelegate>(new InnerImplementingClass(), new InnerEventArgs(), Console.WriteLine);
List<InnerEnum> innerEnums = new List<InnerEnum>();
InnerStruct[] innerStructs = new InnerStruct[10];
Lazy<InnerStruct.InnerStructInnerEnum> innerStructInnerEnum = new Lazy<InnerStruct.InnerStructInnerEnum>();
IEnumerable<InnerStruct.IInnerStructInnerInterface> innerStructInnerInterface = new List<InnerStruct.IInnerStructInnerInterface>();
Dictionary<InnerStruct.InnerStructInnerStruct, InnerStruct.InnerStructInnerClass> innerStructInnerClassByInnerStructInnerStruct =
new Dictionary<InnerStruct.InnerStructInnerStruct,InnerStruct.InnerStructInnerClass>();
Func<InnerAbstractClass, InnerAbstractClass.InnerAbstractClassInnerEnum, InnerAbstractClass.IInnerAbstractClassInnerInterface> getInnerAbstractClass =
(InnerAbstractClass @class, InnerAbstractClass.InnerAbstractClassInnerEnum @enum) => new InnerImplementingClass();
List<Dictionary<InnerAbstractClass.InnerAbstractClassStruct, IEnumerable<InnerImplementingClass[]>>> stuff =
new List<Dictionary<InnerAbstractClass.InnerAbstractClassStruct,IEnumerable<InnerImplementingClass[]>>>();
string toStringHolder;
toStringHolder = tuple.ToString();
toStringHolder = tuple.Item1.ToString();
toStringHolder = tuple.Item2.ToString();
toStringHolder = tuple.Item3.ToString();
toStringHolder = innerEnums.ToString();
toStringHolder = innerEnums.First().ToString();
toStringHolder = innerStructs.ToString();
toStringHolder = innerStructs[0].ToString();
toStringHolder = innerStructInnerEnum.ToString();
toStringHolder = innerStructInnerEnum.Value.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Keys.First().ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Values.First().ToString();
toStringHolder = getInnerAbstractClass.ToString();
toStringHolder = stuff.ToString();
toStringHolder = stuff[0].ToString();
toStringHolder = stuff[0].Keys.First().ToString();
toStringHolder = stuff[0].Values.First().ToString();
toStringHolder = stuff[0].Values.First().First().ToString();
}
示例13: ReferenceAllTypesInClosedGenericParametersWithReferences
public void ReferenceAllTypesInClosedGenericParametersWithReferences(
Tuple<IInnerInterface, InnerEventArgs, InnerDelegate> arg0,
List<InnerEnum> innerEnums,
InnerStruct[] innerStructs,
Lazy<InnerStruct.InnerStructInnerEnum> innerStructInnerEnum,
IEnumerable<InnerStruct.IInnerStructInnerInterface> innerStructInnerInterface,
Dictionary<InnerStruct.InnerStructInnerStruct, InnerStruct.InnerStructInnerClass> innerStructInnerClassByInnerStructInnerStruct,
Func<InnerAbstractClass, InnerAbstractClass.InnerAbstractClassInnerEnum, InnerAbstractClass.IInnerAbstractClassInnerInterface> getInnerAbstractClass,
List<Dictionary<InnerAbstractClass.InnerAbstractClassStruct, IEnumerable<InnerImplementingClass[]>>> stuff)
{
string toStringHolder;
toStringHolder = arg0.ToString();
toStringHolder = arg0.Item1.ToString();
toStringHolder = arg0.Item2.ToString();
toStringHolder = arg0.Item3.ToString();
toStringHolder = innerEnums.ToString();
toStringHolder = innerEnums.First().ToString();
toStringHolder = innerStructs.ToString();
toStringHolder = innerStructs[0].ToString();
toStringHolder = innerStructInnerEnum.ToString();
toStringHolder = innerStructInnerEnum.Value.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Keys.First().ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Values.First().ToString();
toStringHolder = getInnerAbstractClass.ToString();
toStringHolder = stuff.ToString();
toStringHolder = stuff[0].ToString();
toStringHolder = stuff[0].Keys.First().ToString();
toStringHolder = stuff[0].Values.First().ToString();
toStringHolder = stuff[0].Values.First().First().ToString();
}
示例14: track
public Form track(Dictionary<string, double> angles, Tuple<JointType, JointType> bone, IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints)
{
int warnRange = 6;
int neckLow = 80;
int neckHigh = 160;
if (bone.ToString().Contains("Neck"))
{
if (angles["neckAngle"] < neckLow || angles["neckAngle"] > neckHigh)
{
return Form.Bad;
}
else if (angles["neckAngle"] < neckLow + warnRange || angles["neckAngle"] > neckHigh - warnRange)
{
return Form.Warn;
}
}
int kneeLow = 60;
if (bone.ToString().Contains("KneeLeft"))
{
if (angles["leftKneeAngle"] < kneeLow)
{
return Form.Bad;
}
else if (angles["leftKneeAngle"] < kneeLow + warnRange)
{
return Form.Warn;
}
}
if (bone.ToString().Contains("KneeRight"))
{
if (angles["rightKneeAngle"] < kneeLow)
{
return Form.Bad;
}
else if (angles["rightKneeAngle"] < kneeLow + warnRange)
{
return Form.Warn;
}
}
int spineWarnMultiplier = 10;
int spineLow = 177;
int spineHigh = 178;
if (bone.ToString().Contains("SpineShoulder"))
{
if (angles["upperBackAngle"] < spineLow || angles["upperBackAngle"] > spineHigh)
{
return Form.Bad;
}
else if (angles["upperBackAngle"] < spineLow + warnRange / spineWarnMultiplier || angles["upperBackAngle"] > spineHigh - warnRange / spineWarnMultiplier)
{
return Form.Warn;
}
}
if (bone.ToString().Contains("SpineMid"))
{
if (angles["lowerBackAngle"] < spineLow || angles["lowerBackAngle"] > spineHigh)
{
return Form.Bad;
}
else if (angles["lowerBackAngle"] < spineLow + warnRange / spineWarnMultiplier || angles["lowerBackAngle"] > spineHigh - warnRange / spineWarnMultiplier)
{
return Form.Warn;
}
}
return Form.Good;
}