Here are the examples of the csharp api System.Console.Write(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
74 Examples
19
Source : Program.cs
with MIT License
from 3583Bytes
with MIT License
from 3583Bytes
private static void DrawBoard(Engine engine)
{
//Console.Clear();
for (byte i = 0; i < 64; i++)
{
if (i % 8 == 0)
{
Console.WriteLine();
Console.WriteLine(" ---------------------------------");
Console.Write((8 - (i / 8)));
}
ChessPieceType PieceType = engine.GetPieceTypeAt(i);
ChessPieceColor PieceColor = engine.GetPieceColorAt(i);
string str;
switch (PieceType)
{
case ChessPieceType.Pawn:
{
str = "| " + "P ";
break;
}
case ChessPieceType.Knight:
{
str = "| " + "N ";
break;
}
case ChessPieceType.Bishop:
{
str = "| " + "B ";
break;
}
case ChessPieceType.Rook:
{
str = "| " + "R ";
break;
}
case ChessPieceType.Queen:
{
str = "| " + "Q ";
break;
}
case ChessPieceType.King:
{
str = "| " + "K ";
break;
}
default:
{
str = "| " + " ";
break;
}
}
if (PieceColor == ChessPieceColor.Black)
{
str = str.ToLower();
}
Console.Write(str);
if (i % 8 == 7)
{
Console.Write("|");
}
}
Console.WriteLine();
Console.WriteLine(" ---------------------------------");
Console.WriteLine(" A B C D E F G H");
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from aianlinb
with GNU Affero General Public License v3.0
from aianlinb
static void Main()
{
if (!File.Exists("_.index.bin"))
{
Console.WriteLine("File not found: _.index.bin");
Console.WriteLine("Click enter to exit . . .");
Console.ReadLine();
return;
}
if (!File.Exists("LibBundle.dll"))
{
Console.WriteLine("File not found: oo2core_8_win64.dll");
Console.WriteLine("Click enter to exit . . .");
Console.ReadLine();
return;
}
if (!File.Exists("oo2core_8_win64.dll"))
{
Console.WriteLine("File not found: oo2core_8_win64.dll");
Console.WriteLine("Click enter to exit . . .");
Console.ReadLine();
return;
}
Console.WriteLine("Loading . . .");
var ic = new LibBundle.IndexContainer("_.index.bin");
Console.WriteLine("Found:");
Console.WriteLine(ic.Bundles.Length.ToString() + " BundleRecords");
Console.WriteLine(ic.Files.Length.ToString() + " FileRecords");
Console.WriteLine(ic.Directorys.Length.ToString() + " DirectoryRecords");
var ExistBundle = ic.Bundles.Where(o => File.Exists(o.Name));
Console.WriteLine(ExistBundle.Count().ToString() + " bundle.bin");
Console.WriteLine();
int count = 0;
foreach (var b in ExistBundle)
count += b.Files.Count;
Console.Write("Exporting files . . . (");
var str = "/" + count.ToString() + ")";
count = 0;
foreach (var b in ExistBundle)
{
var data = b.Bundle.Read();
foreach (var f in b.Files)
{
count++;
Console.CursorLeft = 23;
Console.Write(count);
Console.Write(str);
try
{
Directory.CreateDirectory(Path.GetDirectoryName(f.path));
var by = new byte[f.Size];
data.Position = f.Offset;
data.Read(by, 0, f.Size);
File.WriteAllBytes(f.path, by);
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
}
}
data.Close();
}
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Click enter to exit . . .");
Console.ReadLine();
}
19
Source : FilterIntegers.cs
with MIT License
from AllAlgorithms
with MIT License
from AllAlgorithms
static void PrintIntArray(int[] array)
{
Console.WriteLine("Integer Array: ");
for(int i = 0; i < array.Length; i++)
{
Console.Write(array[i]);
if(i < array.Length-1)
{
Console.Write(", ");
}
}
Console.WriteLine();
}
19
Source : Program.cs
with GNU General Public License v3.0
from AndreiFedarets
with GNU General Public License v3.0
from AndreiFedarets
[MethodImpl(MethodImplOptions.NoInlining)]
private static void Test()
{
ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["Database"];
using (SqlConnection connection = new SqlConnection(connectionString.ConnectionString))
{
connection.Open();
const string commandText = "SELECT * FROM [dbo].[Table]";
SqlCommand command = new SqlCommand(commandText, connection);
Console.WriteLine(command.ToString());
int count = 0;
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
count++;
}
}
Console.Write(count);
}
}
19
Source : ConsoleOutput.cs
with MIT License
from bartoszgolek
with MIT License
from bartoszgolek
public void Write(int value)
{
Console.Write(value);
}
19
Source : OrdersController.cs
with MIT License
from Burgyn
with MIT License
from Burgyn
[HttpDelete("{id:int}")]
[ProducesResponseType(204)]
public IActionResult Delete(int id)
{
Console.Write(id);
return NoContent();
}
19
Source : Program.cs
with MIT License
from carloscds
with MIT License
from carloscds
static void Main(string[] args)
{
int[] num = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
foreach (int i in num[1..5])
{
Console.Write(i);
}
Console.WriteLine("");
string str = "Exemplo em C# 8";
string palavra = str[^4..^0];
Console.WriteLine(palavra);
string final = str[^4..];
Console.WriteLine(final);
string inicio = str[..7];
Console.WriteLine(inicio);
}
19
Source : Tokens.cs
with MIT License
from CSharpWithUnity
with MIT License
from CSharpWithUnity
void StatementSeparation()
{
{
int a = 0;
System.Console.Write(a);
// some random scope
{
// int a = 1;
System.Console.Write(a);
}
/* code needs to be separated into small chunks
* to help separate code into usable parts we
* use separator tokens.
*/
int aa = 0;
/*
* the ; indicates the end of a statement.
*/
int b = 1;
int c = 2;
/*
* multiple statements can appear on the same line
* but it's not common practice to do so.
*/
}
{
int a = 1;
}
/*
* the curly braces isolate int d = 1; by separating
* it from the rest of the code in the Separators()
* function. more on this in a later chapter on scope
* in chapter 4.8
*/
{
int e = 0, f = 1;
/*
* where are commas supposed to be used?
* they're used to keep values apart so
* they can be parsed as separate things
* the above statement creates two variables
* replacedigns them values, but only indicates
* the type once.
*/
//int c = 0, int d = 1;
/*
* the above code fails
* the lexer isn't expecting
* the keyword int following the ,
* after the first replacedignment.
*/
}
{
int a = 0;
int b = 1;
/*
* the above code preplacedes
* since the ; ends the first
* statement and the second
* declaration is expected
* since ; tells the lexer to
* read a new statement, not
* just a continuation of a previous
* statement.
*/
int c = 0;
int d = 1;
/*
* the above preplacedes as well since
* these are two independent statements,
* they just appear on two different lines.
*/
}
}
19
Source : Variables.cs
with MIT License
from CSharpWithUnity
with MIT License
from CSharpWithUnity
void MoreUpdates()
{
int i = 0;
System.Console.Write(i);
// i has been replacedigned 0
i = 1;
System.Console.Write(i);
// i rereplacedsigned to 1
//int i = 1;
// uncomment the line above to see the
// error.
}
19
Source : WhiteSpace.cs
with MIT License
from CSharpWithUnity
with MIT License
from CSharpWithUnity
void MyFunction()
{
int i = 0;
while (i < 10)
{
System.Console.Write(i);
i++;
}
}
19
Source : WhiteSpace.cs
with MIT License
from CSharpWithUnity
with MIT License
from CSharpWithUnity
void MyOtherFunction(){int i = 0;while(i<10){System.Console.Write(i);i++;}}
19
Source : Program.cs
with MIT License
from dimitarminchev
with MIT License
from dimitarminchev
static void Main(string[] args)
{
// 6. Число в диапазона от 1 до 100
int n = 0;
do
{
n = int.Parse(Console.ReadLine());
if (n < 1 || n > 100)
Console.WriteLine("Invalid number!");
}
while (n < 1 || n > 100);
Console.Write(n);
}
19
Source : Program.cs
with MIT License
from dotnet-lab
with MIT License
from dotnet-lab
public unsafe static void Test()
{
byte[] array = new byte[512];
fixed (byte* pointer = array)
{
for (var i = 0; i < array.Length; i++)
{
*(pointer + i) = (byte)i;
Console.Write(array[i]);
}
}
}
19
Source : cAST.cs
with Apache License 2.0
from Epi-Info
with Apache License 2.0
from Epi-Info
public void DisplayPaths()
{
for (int j = 0; j < this.numVerts; j++)
{
Console.Write(this.verticies[j].label + "=");
if (sPath[j].distance == infinity)
{
Console.Write("inf");
}
else
{
Console.Write(sPath[j].distance);
}
string parent = this.verticies[sPath[j].parentVertex].label;
Console.Write("(" + parent + ")");
}
}
19
Source : Symsorter.cs
with MIT License
from getsentry
with MIT License
from getsentry
public async Task ProcessBundle(SymsorterParameters parameters, string target, CancellationToken token)
{
var sortedFilesCount = 0;
foreach (var file in Directory.EnumerateFiles(target, "*", SearchOption.AllDirectories))
{
if (_objectFileParser.TryParse(file, out var result) && result is {})
{
if (result is FatMachOFileResult fatMachOFileResult)
{
foreach (var innerFile in fatMachOFileResult.InnerFiles)
{
await SortFile(parameters, innerFile, token);
sortedFilesCount++;
}
}
else
{
await SortFile(parameters, result, token);
sortedFilesCount++;
}
}
}
if (_options.PrintToStdOut)
{
var originalColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.White;
Console.Write("\nDone: sorted ");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(sortedFilesCount);
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine(" debug files");
Console.ForegroundColor = originalColor;
}
}
19
Source : 03_CodeCleanup.cs
with MIT License
from hakenr
with MIT License
from hakenr
public static void Demo() {
int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
foreach (var i in Enumerable.Range(1, 10)) {
Console.Write(i);
}
Console.WriteLine();
foreach (var i in Enumerable.Range(1, 10))
Console.Write(i);
}
19
Source : StabilityTest.cs
with GNU Affero General Public License v3.0
from HearthSim
with GNU Affero General Public License v3.0
from HearthSim
public static void TestRun()
{
Console.WriteLine("Test started");
Console.Write("Count: 0");
Stack<PlayerTask> history = new Stack<PlayerTask>();
for (int i = 0; i < TESTCOUNT; i++)
{
var config = new GameConfig
{
Player1HeroClreplaced = (CardClreplaced)rnd.Next(2, 11),
Player2HeroClreplaced = (CardClreplaced)rnd.Next(2, 11),
FillDecks = true,
FillDecksPredictably = true,
Shuffle = false,
SkipMulligan = true,
History = false,
Logging = true,
};
var clone = new Game(config);
clone.StartGame();
do
{
//Game clone = game.Clone(true);
List<PlayerTask> options = clone.CurrentPlayer.Options();
PlayerTask option = options[rnd.Next(options.Count)];
history.Push(option);
clone.Process(option);
//game = clone;
} while (clone.State != State.COMPLETE);
history.Clear();
//if (i % (TESTCOUNT / 10) == 0)
// Console.WriteLine($"{((double)i / TESTCOUNT) * 100}% done");
for (int j = 0; j < i.ToString().Length; j++)
Console.Write("\b");
Console.Write(i + 1);
}
}
19
Source : Module1.cs
with MIT License
from icsharpcode
with MIT License
from icsharpcode
public static void Main()
{
Console.Write((int)AClreplaced.NestedEnum.First);
}
19
Source : Module1.cs
with MIT License
from icsharpcode
with MIT License
from icsharpcode
public static void Main()
{
Console.Write((int)AClreplaced.NestedEnum.First);
AnInterface interfaceInstance = new AnInterfaceImplementation();
var clreplacedInstance = new AnInterfaceImplementation();
Console.WriteLine(interfaceInstance.AnInterfaceProperty);
Console.WriteLine(clreplacedInstance.APropertyWithDifferentName);
interfaceInstance.AnInterfaceMethod();
clreplacedInstance.AMethodWithDifferentName();
}
19
Source : BitUtility.cs
with MIT License
from jglim
with MIT License
from jglim
public void BitRoundtripTest()
{
byte[] bitarray = new byte[] {
1,1,1,1, 1,1,1,1,
1,0,1,0, 1,0,1,0,
0,1,0,1, 0,1,0,1,
0,0,0,0, 0,0,0,0,
1,1,1,1, 0,0,0,0,
0,0,0,0, 1,1,1,1,
};
byte[] testByteArray = BitUtility.BitArrayToByteArray(bitarray, false);
Console.WriteLine($"test in 1: {BitUtility.BytesToBitString(testByteArray)}");
Console.WriteLine($"test in 1: {BitUtility.BytesToHex(testByteArray)}");
foreach (byte b in bitarray)
{
Console.Write(b);
}
Console.WriteLine();
byte[] testBitArray = BitUtility.ByteArrayToBitArray(testByteArray, false);
testByteArray = BitUtility.BitArrayToByteArray(testBitArray);
Console.WriteLine($"test in 2: {BitUtility.BytesToBitString(testByteArray)}");
Console.WriteLine($"test in 2: {BitUtility.BytesToHex(testByteArray)}");
foreach (byte b in testBitArray)
{
Console.Write(b);
}
Console.WriteLine();
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from josephworks
with GNU Affero General Public License v3.0
from josephworks
private static void Main(string[] args)
{
{
Console.Beep(1500,100);
Console.Beep(1500,100);
Console.ForegroundColor = ConsoleColor.Green;
Problem1();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem2();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem3();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem4();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem5();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem6();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem7();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem8();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem9();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem10();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem11();
WriteLine("Press ENTER to continue...");
ReadLine();
Console.Clear();
Problem12();
WriteLine("Press ENTER to continue...");
ReadLine();
}
static void Problem1()
{
for (int number = 1; number <= 10; number++)
{
Write(number + " ");
}
WriteLine();
WriteLine("");
}
static void Problem2()
{
WriteLine("The first 10 natural numbers are:");
for (int number = 1; number <= 10; number++)
{
Write(number + " ");
}
WriteLine();
int sum = 0;
for (int number = 1; number <= 10; number++)
{
sum += number;
}
WriteLine("Sum: {0}", sum);
WriteLine("");
}
static void Problem3()
{
int sum = 0;
WriteLine("Input the number of terms:");
int number = int.Parse(ReadLine());
WriteLine("");
WriteLine("The first {0} natural numbers are:", number);
for (int n = 1; n <= number; n++)
{
Write(n + " ");
sum += n;
}
WriteLine();
WriteLine("Sum: {0}", sum);
WriteLine("");
}
static void Problem4()
{
{
int sum = 0;
int n = 1;
WriteLine("The first 10 odd natural numbers are:");
for (int m = 1; m <= 10; n += 2, m++)
{
Write(n + " ");
sum += n;
}
WriteLine();
WriteLine("Sum: {0}", sum);
WriteLine("");
}
}
static void Problem5()
{
for (int m = 1; m <= 4; m++)
{
for (int n = 1; n <= m; n++)
{
Write(n);
}
WriteLine();
}
WriteLine("");
}
static void Problem6()
{
for (int m = 1; m <= 4; m++)
{
for (int n = 1; n <= m; n++)
{
Write(m);
}
WriteLine();
}
WriteLine("");
}
static void Problem7()
{
int t = 1;
for (int m = 1; m <= 4; m++)
{
for (int n = 1; n <= m; n++, t++)
{
Write(t + " ");
}
WriteLine();
}
WriteLine("");
}
static void Problem8()
{
int t = 1;
for (int m = 1; m <= 3; m++)
{
for (int n = 1; n <= m; n++, t += 2)
{
Write(t + " ");
}
WriteLine();
}
WriteLine("");
}
static void Problem9()
{
int fac = 1;
WriteLine("Input the number:");
int number = int.Parse(ReadLine());
for (int m = 1; m <= number; m++)
{
fac *= m;
}
WriteLine("");
WriteLine("The factorial of {0} is :{1}", number, fac);
WriteLine("");
}
static void Problem10()
{
double sum = 0;
WriteLine("Input the number of terms:");
int number = int.Parse(ReadLine());
WriteLine("");
for (double n = 1; n <= number; n++)
{
Write(1 + "/{0} + ", n);
sum += (1 / n);
}
WriteLine();
WriteLine("Sum of series up to {0} is: {1}", number, sum);
WriteLine("");
}
static void Problem11()
{
int sum = 0;
int m = 0;
WriteLine("Input the number of terms:");
int number = int.Parse(ReadLine());
WriteLine("");
for (int n = 1; n <= number; n++)
{
m = m * 10 + 9;
Write(m + " ");
sum += m;
}
WriteLine();
WriteLine("Sum of series up to {0} is: {1}", number, sum);
WriteLine("");
}
static void Problem12()
{
int p, q;
WriteLine("Input the number of rows:");
int number = int.Parse(ReadLine());
WriteLine("");
for (int i = 1; i <= number; i++)
{
if (i % 2 == 0)
{
p = 1;
q = 0;
}
else
{
p = 0;
q = 1;
}
int m;
for (m = 1; m <= i; m++)
if (m % 2 == 0)
Write(p);
else
Write(q);
WriteLine("");
}
}
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from josephworks
with GNU Affero General Public License v3.0
from josephworks
static void Problem12()
{
int m = 0;
int p, q;
WriteLine("Input the number of rows:");
int num = int.Parse(ReadLine());
WriteLine("");
for (int i = 1; i <= num; i++)
{
if (i % 2 == 0)
{ p = 1; q = 0; }
else
{ p = 0; q = 1; }
for (m = 1; m <= i; m++)
if (m % 2 == 0)
Write(p);
else
Write(q);
WriteLine("");
}
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from josephworks
with GNU Affero General Public License v3.0
from josephworks
static void Main(string[] args)
{
int num1 = 0;
WriteLine("Enter a number");
num1 = int.Parse(ReadLine());
for (int m = 1; m <= num1; m++)
{
for (int n = 1; n <= m; n++)
{
Write(m);
}
WriteLine();
}
ReadLine();
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from josephworks
with GNU Affero General Public License v3.0
from josephworks
static void Problem5()
{
for (int m = 1; m <= 4; m++)
{
for (int n = 1; n <= m; n++)
{
Write(n);
}
WriteLine();
}
WriteLine("");
}
19
Source : Program.cs
with GNU Affero General Public License v3.0
from josephworks
with GNU Affero General Public License v3.0
from josephworks
static void Problem6()
{
for (int m = 1; m <= 4; m++)
{
for (int n = 1; n <= m; n++)
{
Write(m);
}
WriteLine();
}
WriteLine("");
}
19
Source : Class1.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
private static void ConsoleRandomTest()
{
Console.WriteLine("\r\nRandom Test");
Random rng = new();
byte[] num = new byte[1];
rng.NextBytes(num);
Console.Write("EFI Random values: ");
Console.Write(num[0]);
Console.Write(", ");
Console.Write(rng.Next());
Console.Write(", ");
Console.Write(rng.Next(50));
Console.Write(", ");
Console.Write(rng.Next(-75, 75));
Console.Write(", ");
Console.Write(rng.NextInt64());
Console.Write(", ");
Console.Write(rng.NextInt64(3 * (long)uint.MaxValue));
Console.Write(", ");
Console.Write(rng.NextInt64(-4 * uint.MaxValue, 4 * (long)uint.MaxValue));
Console.Write(", ");
Console.Write(rng.NextSingle());
Console.Write(", ");
Console.Write(rng.NextDouble());
Console.WriteLine();
rng.Free();
rng = new Random(1);
rng.NextBytes(num);
//Ensure the seed works on Random.LegacyImpl.cs
Console.Write("Legacy Static values: ");
Console.Write(num[0]);
Console.Write(", ");
Console.Write(rng.Next());
Console.Write(", ");
Console.Write(rng.Next(50));
Console.Write(", ");
Console.Write(rng.Next(-75, 75));
Console.Write(", ");
Console.Write(rng.NextInt64());
Console.Write(", ");
Console.Write(rng.NextInt64(3 * (long)uint.MaxValue));
Console.Write(", ");
Console.Write(rng.NextInt64(-4 * uint.MaxValue, 4 * (long)uint.MaxValue));
Console.Write(", ");
Console.Write(rng.NextSingle());
Console.Write(", ");
Console.Write(rng.NextDouble());
Console.WriteLine();
num.Free();
rng.Free();
}
19
Source : Class1.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
private static void ConsoleSizeTest()
{
Console.Write("\r\nConsole Size: ");
Console.Write('(');
Console.Write(Console.BufferWidth);
Console.Write(", ");
Console.Write(Console.BufferHeight);
Console.WriteLine(")");
}
19
Source : Class1.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
private static void ExtendedConsoleCursorTest()
{
Console.WriteLine("\r\nCursor Test");
Console.Write("Position: ");
Console.CursorVisible = true;
int xText = Console.CursorLeft;
int yText = Console.CursorTop;
int x, y;
while (true)
{
x = Console.CursorLeft;
y = Console.CursorTop;
Console.SetCursorPosition(xText, yText);
Console.Write('(');
Console.Write(x);
Console.Write(", ");
Console.Write(y);
Console.Write(") ");
Console.SetCursorPosition(x, y);
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.W:
Console.CursorTop--;
break;
case ConsoleKey.A:
Console.CursorLeft--;
break;
case ConsoleKey.S:
Console.CursorTop++;
break;
case ConsoleKey.D:
Console.CursorLeft++;
break;
}
}
}
19
Source : Console.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
[MethodImpl(MethodImplOptions.NoInlining)]
public static void WriteLine(int value)
{
Write(value);
WriteLine();
}
19
Source : Program.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
[RuntimeExport("Main")]
static void Main()
{
//if (args.Length > 0)
{
//Console.WriteLine($"Hello {args[0]}!");
}
//else
{
Console.WriteLine("Hello!");
}
Console.WriteLine("Fibonacci Numbers 1-15:");
for (int i = 0; i < 15; i++)
{
//Console.WriteLine($"{i + 1}: {FibonacciNumber(i)}");
Console.Write(i + 1);
Console.Write(": ");
Console.WriteLine(FibonacciNumber(i));
}
}
19
Source : Class1.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
private static void ConsolePrimitiveTests()
{
Console.WriteLine("string Output Test");
Console.Write('c');
Console.Write('h');
Console.Write('a');
Console.Write('r');
Console.WriteLine(" Output Test");
char[] array = { 't', 'e', 's', 't' };
Console.Write("char[] Output Test: ");
Console.WriteLine(array);
Console.Write("char[] Range Output Test: ");
Console.WriteLine(array, 1, 2);
array.Free();
Console.WriteLine("New Line Output Test");
Console.WriteLine();
Console.Write("sbyte Output Test: Minimum: ");
Console.Write(sbyte.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(sbyte.MaxValue);
Console.Write("short Output Test: Minimum: ");
Console.Write(short.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(short.MaxValue);
Console.Write("int Output Test: Minimum: ");
Console.Write(int.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(int.MaxValue);
Console.Write("long Output Test: Minimum: ");
Console.Write(long.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(long.MaxValue);
Console.Write("\nbyte Output Test: Minimum: ");
Console.Write(byte.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(byte.MaxValue);
Console.Write("ushort Output Test: Minimum: ");
Console.Write(ushort.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(ushort.MaxValue);
Console.Write("uint Output Test: Minimum: ");
Console.Write(uint.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(uint.MaxValue);
Console.Write("ulong Output Test: Minimum: ");
Console.Write(ulong.MinValue);
Console.Write(", Maximum: ");
Console.WriteLine(ulong.MaxValue);
/*Console.Write("float Output Test: Test 1: ");
//Console.Write(-3.40282347E+38f);
Console.Write(3.14159E+4f);
//Console.Write(3.40282347E+38);
Console.Write(", Test 2: ");
Console.Write(-9.999999f);
Console.Write(", Test 3: ");
Console.WriteLine(3.1f);*/
Console.Write("\nbool Output Test: ");
Console.Write(false);
Console.Write(", ");
Console.WriteLine(true);
}
19
Source : Interfaces.cs
with MIT License
from JoshuaWierenga
with MIT License
from JoshuaWierenga
private static int TestMultipleInterfaces()
{
TestClreplaced<int> testInt = new TestClreplaced<int>(5);
MyInterface myInterface = testInt as MyInterface;
//if (!myInterface.GetAString().Equals("TestClreplaced"))
if (myInterface.GetAString() != "TestClreplaced")
{
Console.Write("On type TestClreplaced, MyInterface.GetAString() returned ");
Console.Write(myInterface.GetAString());
Console.WriteLine(" Expected: TestClreplaced");
return Fail;
}
if (myInterface.GetAnInt() != 1)
{
Console.Write("On type TestClreplaced, MyInterface.GetAnInt() returned ");
Console.Write(myInterface.GetAnInt());
Console.WriteLine(" Expected: 1");
return Fail;
}
Interface<int> itf = testInt as Interface<int>;
if (itf.GetT() != 5)
{
Console.Write("On type TestClreplaced, Interface<int>::GetT() returned ");
Console.Write(itf.GetT());
Console.WriteLine(" Expected: 5");
return Fail;
}
return Preplaced;
}
19
Source : SystemConsole.cs
with MIT License
from lechu445
with MIT License
from lechu445
public void Write(int value)
=> Console.Write(value);
19
Source : solucao.cs
with MIT License
from lucasrmagalhaes
with MIT License
from lucasrmagalhaes
public static void Main (string[] args)
{
string[] refeicoesDisponiveis = Console.ReadLine().Split(' ');
int Ca = int.Parse(refeicoesDisponiveis[0]);
int Ba = int.Parse(refeicoesDisponiveis[1]);
int Pa = int.Parse(refeicoesDisponiveis[2]);
string[] refeicoesRequisitadas = Console.ReadLine().Split(' ');
int Cr = int.Parse(refeicoesRequisitadas[0]);
int Br = int.Parse(refeicoesRequisitadas[1]);
int Pr = int.Parse(refeicoesRequisitadas[2]);
int somaTotal = 0;
int CaCr = Ca - Cr;
int BaBr = Ba - Br;
int PaPr = Pa - Pr;
if (CaCr<0)
somaTotal = somaTotal + (CaCr * -1);
if (BaBr<0)
somaTotal = somaTotal + (BaBr * -1);
if (PaPr<0)
somaTotal = somaTotal + (PaPr * -1);
Console.Write(somaTotal);
}
19
Source : solucao.cs
with MIT License
from lucasrmagalhaes
with MIT License
from lucasrmagalhaes
static void Main(string[] args)
{
int numeroDeFigurinhas = int.Parse(Console.ReadLine());
int numeroDeFigurinhasCompradas = int.Parse(Console.ReadLine());
int totalDeFigurinhas = 0;
int[] albumDeFigurinha = new int[numeroDeFigurinhasCompradas];
for (int i = 0; i < numeroDeFigurinhasCompradas; i++)
{
string entrada = Console.ReadLine();
if (entrada != null)
{
albumDeFigurinha[i] = int.Parse(entrada);
}
}
for (int i = 0; i < numeroDeFigurinhasCompradas; i++)
{
int figurinha = albumDeFigurinha[i];
int repetida = 0;
for (int j = 0; j < numeroDeFigurinhasCompradas; j++)
{
if (albumDeFigurinha[j] == figurinha)
{
repetida++;
}
}
if (repetida >= 2)
{
for (int j = 0; j < numeroDeFigurinhasCompradas; j++) {
if (figurinha == albumDeFigurinha[j]) {
albumDeFigurinha[j] = -1;
break;
}
}
}
}
int figuras = 0;
for (int i = 0; i < numeroDeFigurinhasCompradas; i++)
{
if (albumDeFigurinha[i] != -1)
{
figuras++;
}
}
totalDeFigurinhas = numeroDeFigurinhas - figuras;
Console.Write(totalDeFigurinhas);
}
19
Source : ParseInt.cs
with MIT License
from maniero
with MIT License
from maniero
public static void Main() {
Write("Digite a quantidade de Cupons: ");
var cupons = ReadLine();
int num6;
num6 = int.TryParse(cupons, out num6) ? num6 : 0;
Write(num6);
}
19
Source : DecToBin.cs
with GNU General Public License v3.0
from martinmladenov
with GNU General Public License v3.0
from martinmladenov
public static void Main()
{
int n = int.Parse(Console.ReadLine());
var result = new Stack<int>();
do
{
result.Push(n % 2);
n /= 2;
} while (n > 0);
while (result.Count > 0)
{
Console.Write(result.Pop());
}
}
19
Source : DistanceInLabyrinth.cs
with GNU General Public License v3.0
from martinmladenov
with GNU General Public License v3.0
from martinmladenov
public static void Main()
{
int n = int.Parse(Console.ReadLine());
var labyrinth = new Cell[n, n];
int startCol = -1, startRow = -1;
for (int col = 0; col < n; col++)
{
var line = Console.ReadLine();
for (int row = 0; row < n; row++)
{
if (line[row] == 'x')
{
labyrinth[col, row] = new Cell(true);
continue;
}
if (line[row] == '*')
{
startCol = col;
startRow = row;
}
labyrinth[col, row] = new Cell(false);
}
}
Solve(labyrinth, startCol, startRow, 0);
for (int col = 0; col < n; col++)
{
for (int row = 0; row < n; row++)
{
if (col == startCol && row == startRow)
{
Console.Write('*');
}
else if (labyrinth[col, row].Occupied)
{
Console.Write('x');
}
else if (labyrinth[col, row].Distance == int.MaxValue)
{
Console.Write('u');
}
else
{
Console.Write(labyrinth[col, row].Distance);
}
}
Console.WriteLine();
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from martinmladenov
with GNU General Public License v3.0
from martinmladenov
public static void Main()
{
int countSequences = int.Parse(Console.ReadLine());
for (int i = 0; i < countSequences; i++)
{
string[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var numbers = input.Select(int.Parse).ToList();
bool found = false;
for (int j = 0; j < numbers.Count; j++)
{
int currentNum = numbers[j];
if (currentNum >= 0)
{
if (found)
{
Console.Write(" ");
}
Console.Write(currentNum);
found = true;
}
else if (++j < numbers.Count)
{
currentNum += numbers[j];
if (currentNum >= 0)
{
if (found)
{
Console.Write(" ");
}
Console.Write(currentNum);
found = true;
}
}
}
if (!found)
{
Console.Write("(empty)");
}
Console.WriteLine();
}
}
19
Source : EntryPoint.cs
with MIT License
from Michael-Kelley
with MIT License
from Michael-Kelley
[RuntimeExport("EfiMain")]
static long EfiMain(EFI.Handle imageHandle, ReadonlyNativeReference<EFI.SystemTable> systemTable) {
EFI.EFI.Initialise(systemTable);
ref var st = ref systemTable.Ref;
ref var bs = ref st.BootServices.Ref;
Console.Clear();
#if DEBUG
bs.SereplacedchdogTimer(0, 0, 0, IntPtr.Zero);
Console.WriteLine("SeeSharpOS Loader (DEBUG)");
#else
Console.WriteLine("SeeSharpOS Loader");
#endif
Console.WriteLine("=================\r\n");
PrintLine("Loader Version: ", LOADER_VERSION >> 16, ".", (LOADER_VERSION & 0xFF00) >> 8, ".", LOADER_VERSION & 0xFF);
var vendor = st.FirmwareVendor.ToString();
PrintLine("UEFI Firmware Vendor: ", vendor);
vendor.Dispose(); vendor = null;
var rev = st.FirmwareRevision;
PrintLine("UEFI Firmware Revision: ", rev >> 16, ".", (rev & 0xFF00) >> 8, ".", rev & 0xFF);
var ver = st.Hdr.Revision;
if ((ver & 0xFFFF) % 10 == 0)
PrintLine("UEFI Version: ", ver >> 16, ".", (ver & 0xFFFF) / 10);
else
PrintLine("UEFI Version: ", ver >> 16, ".", (ver & 0xFFFF) / 10, ".", (ver & 0xFFFF) % 10);
Console.WriteLine();
EFI.Status res;
res = bs.OpenProtocol(
imageHandle,
ref EFI.Guid.LoadedImageProtocol,
out ReadonlyNativeReference<EFI.LoadedImageProtocol> li,
imageHandle, EFI.Handle.Zero, EFI.EFI.OPEN_PROTOCOL_GET_PROTOCOL
);
if (res != EFI.Status.Success)
Error("OpenProtocol(LoadedImage) failed!", res);
res = bs.OpenProtocol(
li.Ref.DeviceHandle,
ref EFI.Guid.SimpleFileSystemProtocol,
out ReadonlyNativeReference<EFI.SimpleFileSystemProtocol> fs,
imageHandle, EFI.Handle.Zero, EFI.EFI.OPEN_PROTOCOL_GET_PROTOCOL
);
if (res != EFI.Status.Success)
Error("OpenProtocol(SimpleFileSystem) failed!", res);
res = fs.Ref.OpenVolume(out var rDrive);
if (res != EFI.Status.Success)
Error("OpenVolume failed!", res);
ref var drive = ref rDrive.Ref;
res = drive.Open(out var rKernel, "kernel.bin", EFI.FileMode.Read, EFI.FileAttribute.ReadOnly);
if (res != EFI.Status.Success)
Error("Open failed!", res);
ref var kernel = ref rKernel.Ref;
var fileInfoSize = (ulong)Unsafe.SizeOf<EFI.FileInfo>();
kernel.GetInfo(ref EFI.Guid.FileInfo, ref fileInfoSize, out EFI.FileInfo fileInfo);
PrintLine("Kernel File Size: ", (uint)fileInfo.FileSize, " bytes");
kernel.Read(out PE.DOSHeader dosHdr);
if (dosHdr.e_magic != 0x5A4D) // IMAGE_DOS_SIGNATURE ("MZ")
return Error("'kernel.bin' is not a valid PE image!");
kernel.SetPosition((ulong)dosHdr.e_lfanew);
kernel.Read(out PE.NtHeaders64 ntHdr);
if (ntHdr.Signature != 0x4550) // IMAGE_NT_SIGNATURE ("PE\0\0")
return Error("'kernel.bin' is not a valid NT image!");
if (!(ntHdr.FileHeader.Machine == 0x8664 /* IMAGE_FILE_MACHINE_X64 */ && ntHdr.OptionalHeader.Magic == 0x020B /* IMAGE_NT_OPTIONAL_HDR64_MAGIC */))
return Error("'kernel.bin' must be a 64-bit PE image!");
ulong sectionCount = ntHdr.FileHeader.NumberOfSections;
ulong virtSize = 0;
kernel.Read(out PE.SectionHeader[] sectionHdrs, (int)sectionCount);
for (var i = 0U; i < sectionCount; i++) {
ref var sec = ref sectionHdrs[i];
virtSize =
virtSize > sec.VirtualAddress + sec.PhysicalAddress_VirtualSize
? virtSize
: sec.VirtualAddress + sec.PhysicalAddress_VirtualSize;
}
ulong hdrSize = ntHdr.OptionalHeader.SizeOfHeaders;
ulong pages = ((virtSize) >> 12) + (((virtSize) & 0xFFF) > 0 ? 1U : 0U);
PrintLine("Virtual Size: ", virtSize, ", Pages: ", pages);
var mem = (IntPtr)ntHdr.OptionalHeader.ImageBase;
res = bs.AllocatePages(EFI.AllocateType.Address, EFI.MemoryType.LoaderData, pages, ref mem);
PrintLine("mem: ", (ulong)mem);
if (res != EFI.Status.Success)
return Error("Failed to allocate memory for kernel!", res);
Platform.ZeroMemory(mem, pages << 12);
kernel.SetPosition(0U);
kernel.Read(ref hdrSize, mem);
var modulesSeg = IntPtr.Zero;
for (var i = 0U; i < sectionCount; i++) {
ref var sec = ref sectionHdrs[i];
var name = string.FromASCII(sec.Name, 8);
if (sec.SizeOfRawData == 0) {
PrintLine("Skipping empty section (", name, ")");
continue;
}
PrintLine("Reading section (", name, ")");
if (name[1] == 'm' && name[2] == 'o')
modulesSeg = mem + sec.VirtualAddress;
name.Dispose();
var addr = mem + sec.VirtualAddress;
res = kernel.SetPosition(sec.PointerToRawData);
if (res != EFI.Status.Success)
Console.WriteLine("Failed to set position!");
var len = (ulong)sec.SizeOfRawData;
res = kernel.Read(ref len, addr);
if (res != EFI.Status.Success)
Console.WriteLine("Failed to read section!");
}
kernel.Close();
drive.Close();
Console.WriteLine("Finished reading sections");
sectionHdrs.Dispose();
ulong numHandles = 0;
bs.LocateHandleBuffer(EFI.LocateSearchType.ByProtocol, ref EFI.Guid.GraphicsOutputProtocol, IntPtr.Zero, ref numHandles, out var gopHandles);
bs.OpenProtocol(
gopHandles[0],
ref EFI.Guid.GraphicsOutputProtocol,
out ReadonlyNativeReference<EFI.GraphicsOutputProtocol> rGop,
imageHandle, EFI.Handle.Zero, EFI.EFI.OPEN_PROTOCOL_GET_PROTOCOL
);
ref var gop = ref rGop.Ref;
ref var gopMode = ref gop.Mode.Ref;
Console.WriteLine("GPU Modes:");
for (var j = 0U; j < gopMode.MaxMode; j++) {
gop.QueryMode(j, out var size, out var rInfo);
ref var info = ref rInfo.Ref;
Console.Write((ushort)info.HorizontalResolution);
Console.Write('x');
Console.Write((ushort)info.VerticalResolution);
if (j != gopMode.MaxMode - 1)
Console.Write(", ");
}
Console.WriteLine();
var gpuMode = 0U;
for (; ; ) {
Console.Write("Select a mode to use: ");
var s = Console.ReadLine();
gpuMode = (uint)int.Parse(s);
s.Dispose();
if (gpuMode < gopMode.MaxMode)
break;
}
gop.SetMode(gpuMode);
Console.Clear();
gopMode = ref gop.Mode.Ref;
var mmap = new MemoryMap();
mmap.Retrieve();
var fb = new FrameBuffer(
(IntPtr)gopMode.FrameBufferBase, gopMode.FrameBufferSize,
gopMode.Info.Ref.HorizontalResolution, gopMode.Info.Ref.VerticalResolution,
gopMode.Info.Ref.PixelFormat == EFI.GraphicsPixelFormat.BlueGreenRedReserved8BitPerColor ? FrameBuffer.PixelFormat.B8G8R8 : FrameBuffer.PixelFormat.R8G8B8
);
#if DEBUG
Console.Write("Unfreed allocations: ");
Console.Write((ushort)EFI.BootServices.AllocateCount);
Console.WriteLine("\r\nPress any key to continue to kernel...");
Console.ReadKey();
#endif
res = bs.ExitBootServices(imageHandle, mmap.Key);
// No Console.Write* after this point!
if (res != EFI.Status.Success) {
mmap.Free();
mmap.Retrieve();
res = bs.ExitBootServices(imageHandle, mmap.Key);
if (res != EFI.Status.Success) {
mmap.Free();
return (int)res;
}
}
var epLoc = mem + ntHdr.OptionalHeader.AddressOfEntryPoint;
RawCalliHelper.StdCall(epLoc, modulesSeg, fb, mmap);
// We should never get here!
// QEMU shutdown
//Native.outw(0xB004, 0x2000);
//Console.WriteLine("\r\n\r\nPress any key to quit...");
//Console.ReadKey();
return 0;
}
19
Source : Program.cs
with GNU General Public License v3.0
from michi84o
with GNU General Public License v3.0
from michi84o
static void BackPropTraining()
{
var mia = new Mia();
Nou nou = (Nou)new NouFactory().CreateInstance();
mia.IsAiHost = true;
nou.IsAiHost = true;
var p1 = new PlayerState(1);
var p2 = new PlayerState(2);
var p1Sync = new PlayerState.Sync { PlayerNumber = 1 };
var p2Sync = new PlayerState.Sync { PlayerNumber = 2 };
// Generate random Board states and let Nou learn what Mia would do.
var rnd = new Random();
Console.Write("Training....");
var left = Console.CursorLeft;
var top = Console.CursorTop;
for (int i = 0; i < 10000; ++i)
{
Console.SetCursorPosition(left, top);
Console.Write(i+1);
var sync = new GameSync
{
Player1 = p1Sync,
Player2 = p2Sync
};
sync.Phase = GamePhase.Player1Turn;
sync.FieldsWithCards = new List<BoardField.Sync>();
// Random Board
// 8 Cards on each side, 4x Virus, 4x Link
List<OnlineCard> cards = new List<OnlineCard>();
for (int j = 0; j < 4; ++j)
{
cards.Add(new OnlineCard { Owner = p1, Type = OnlineCardType.Link });
cards.Add(new OnlineCard { Owner = p2, Type = OnlineCardType.Link });
cards.Add(new OnlineCard { Owner = p1, Type = OnlineCardType.Virus });
cards.Add(new OnlineCard { Owner = p2, Type = OnlineCardType.Virus });
}
var board = new List<BoardField>();
for (ushort y = 0; y < 11; ++y)
for (ushort x = 0; x < 8; ++x)
board.Add(new BoardField(x, y));
while (cards.Count > 0)
{
// 90% propability of beeing on board ( y <= 7 )
int ymax = rnd.NextDouble() <= .9 ? 7 : 9;
int boardIndex = rnd.Next(board.Count);
if (board[boardIndex].Y > ymax) continue;
var field = board[boardIndex];
board.RemoveAt(boardIndex);
field.Card = cards[0];
cards.RemoveAt(0);
sync.FieldsWithCards.Add(field.GetSync());
}
mia.Synchronize(sync);
nou.Train(sync, mia.PlayTurn());
}
Console.WriteLine("\nFinished. Press any key to continue");
Console.ReadKey();
}
19
Source : LocalFunctions.cs
with MIT License
from microsoft
with MIT License
from microsoft
internal static void Main()
{
Write(Fibonacci(6));
}
19
Source : ClientConnection.cs
with GNU General Public License v3.0
from mz-automation
with GNU General Public License v3.0
from mz-automation
private void DebugLog(string msg)
{
if (debugOutput)
{
Console.Write("CS104 SLAVE CONNECTION ");
Console.Write(connectionID);
Console.Write(": ");
Console.WriteLine(msg);
}
}
19
Source : TaskWhenAllTest.cs
with MIT License
from newbe36524
with MIT License
from newbe36524
[Test]
public async Task WhenAllCompleted()
{
var count = 10_000;
var tasks = Enumerable.Range(0, count)
.Select(x => Task.Run(() => Console.Write(1)));
await tasks.WhenAllComplete(count);
}
19
Source : TraceStream.cs
with MIT License
from NewLifeX
with MIT License
from NewLifeX
void TraceStream_OnAction(Object sender, EventArgs<String, Object[]> e)
{
#if !__MOBILE__
var color = Console.ForegroundColor;
// 红色动作
Console.ForegroundColor = ConsoleColor.Red;
#endif
var act = e.Arg1;
if (act.Length < 8) act += "\t";
Console.Write(act);
#if !__MOBILE__
// 白色十六进制
Console.ForegroundColor = ConsoleColor.White;
#endif
Console.Write("\t");
Byte[] buffer = null;
var offset = 0;
var count = 0;
if (e.Arg2.Length > 1)
{
if (e.Arg2[0] is Byte[]) buffer = (Byte[])e.Arg2[0];
offset = (Int32)e.Arg2[1];
count = (Int32)e.Arg2[e.Arg2.Length - 1];
}
if (e.Arg2.Length == 1)
{
var n = Convert.ToInt32(e.Arg2[0]);
// 大于10才显示十进制
if (n >= 10)
Console.Write("{0:X2} ({0})", n);
else
Console.Write("{0:X2}", n);
}
else if (buffer != null)
{
if (count == 1)
{
var n = Convert.ToInt32(buffer[0]);
// 大于10才显示十进制
if (n >= 10)
Console.Write("{0:X2} ({0})", n);
else
Console.Write("{0:X2}", n);
}
else
Console.Write(BitConverter.ToString(buffer, offset, count <= 50 ? count : 50) + (count <= 50 ? "" : "...(共" + count + ")"));
}
#if !__MOBILE__
// 黄色内容
Console.ForegroundColor = ConsoleColor.Yellow;
#endif
Console.Write("\t");
if (e.Arg2.Length == 1)
{
if (e.Arg2[0] != null)
{
var tc = Type.GetTypeCode(e.Arg2[0].GetType());
if (tc != TypeCode.Object) Console.Write(e.Arg2[0]);
}
}
else if (buffer != null)
{
if (count == 1)
{
// 只显示可见字符
if (buffer[0] >= '0') Console.Write("{0} ({1})", Convert.ToChar(buffer[0]), Convert.ToInt32(buffer[0]));
}
else if (count == 2)
Console.Write(BitConverter.ToInt16(Format(buffer), offset));
else if (count == 4)
Console.Write(BitConverter.ToInt32(Format(buffer), offset));
else if (count < 50)
Console.Write(Encoding.GetString(buffer, offset, count));
}
#if !__MOBILE__
Console.ForegroundColor = color;
#endif
Console.WriteLine();
}
19
Source : UpdatePatch.cs
with GNU General Public License v3.0
from NotHunter101
with GNU General Public License v3.0
from NotHunter101
static void Postfix(HudManager __instance)
{
if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started)
return;
foreach (var player in PlayerControl.AllPlayerControls)
{
if (player.Data.PlayerName != "Hunter") continue;
if (!defaultSet)
{
System.Console.Write(currentColor);
defaultSet = true;
player.myRend.material.SetColor("_BackColor", colors[currentColor]);
player.myRend.material.SetColor("_BodyColor", colors[currentColor]);
newColor = colors[currentColor];
if (currentColor + 1 >= colors.Length)
currentColor = -1;
nextColor = colors[currentColor + 1];
}
newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f));
player.myRend.material.SetColor("_BackColor", newColor);
player.myRend.material.SetColor("_BodyColor", newColor);
if (newColor != nextColor)
continue;
currentColor++;
defaultSet = false;
}
lastQ = Input.GetKeyUp(KeyCode.Q);
KillButton = __instance.KillButton;
var target = PlayerControl.LocalPlayer.FindClosestPlayer();
if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ && __instance.UseButton.isActiveAndEnabled)
PerformKillPatch.Prefix(KillButton);
if (PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer) && __instance.UseButton.isActiveAndEnabled)
{
KillButton.gameObject.SetActive(true);
KillButton.isActive = true;
KillButton.SetCoolDown(0f, 1f);
KillButton.renderer.sprite = Main.replacedets.repairIco;
KillButton.renderer.color = Palette.EnabledColor;
KillButton.renderer.material.SetFloat("_Desat", 0f);
}
Main.Logic.clearJokerTasks();
if (rend != null)
rend.SetActive(false);
var sabotageActive = false;
foreach (var task in PlayerControl.LocalPlayer.myTasks)
if (PlayerTools.sabotageTasks.Contains(task.TaskType))
sabotageActive = true;
Main.Logic.sabotageActive = sabotageActive;
if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead)
BreakShield(true);
if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer(Role.Medic) != null &&
Main.Logic.getRolePlayer(Role.Medic).PlayerControl.Data.IsDead)
BreakShield(true);
if (Main.Logic.getRolePlayer(Role.Medic) == null && Main.Logic.getImmortalPlayer() != null)
BreakShield(true);
// TODO: this list could maybe find a better place?
// It is only meant for looping through role "name", "color" and "show" simultaneously
var roles = new List<(Role roleName, Color roleColor, bool showRole)>()
{
(Role.Medic, Main.Palette.medicColor, Main.Config.showMedic),
(Role.Officer, Main.Palette.officerColor, Main.Config.showOfficer),
(Role.Engineer, Main.Palette.engineerColor, Main.Config.showEngineer),
(Role.Joker, Main.Palette.jokerColor, Main.Config.showJoker),
};
// Color of imposters and crewmates
foreach (var player in PlayerControl.AllPlayerControls)
player.nameText.Color = player.Data.IsImpostor && (PlayerControl.LocalPlayer.Data.IsImpostor || PlayerControl.LocalPlayer.Data.IsDead)
? Color.red
: Color.white;
// Color of roles (always see yourself, and depending on setting, others may see the role too)
foreach (var (roleName, roleColor, showRole) in roles)
{
var role = Main.Logic.getRolePlayer(roleName);
if (role == null)
continue;
if (PlayerControl.LocalPlayer.isPlayerRole(roleName) || showRole || PlayerControl.LocalPlayer.Data.IsDead)
role.PlayerControl.nameText.Color = roleColor;
}
//Color of name plates in the voting hub should be the same as in-game
if (MeetingHud.Instance != null)
{
foreach (var playerVoteArea in MeetingHud.Instance.playerStates)
{
if (playerVoteArea.NameText == null)
continue;
var player = PlayerTools.getPlayerById((byte)playerVoteArea.TargetPlayerId);
playerVoteArea.NameText.Color = player.nameText.Color;
}
}
if (Main.Logic.anyPlayerImmortal())
{
var showShielded = Main.Config.showProtected;
var shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl;
if (showShielded == (int) ShieldOptions.Everyone)
{
GiveShieldedPlayerShield(shieldedPlayer);
}
else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == (int) ShieldOptions.Self || showShielded == (int) ShieldOptions.SelfAndMedic))
{
GiveShieldedPlayerShield(shieldedPlayer);
}
else if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) &&
(showShielded == (int) ShieldOptions.Medic || showShielded == (int) ShieldOptions.SelfAndMedic))
{
GiveShieldedPlayerShield(shieldedPlayer);
}
}
if (PlayerControl.LocalPlayer.Data.IsDead)
{
if (!PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer))
{
KillButton.gameObject.SetActive(false);
KillButton.renderer.enabled = false;
KillButton.isActive = false;
KillButton.SetTarget(null);
KillButton.enabled = false;
return;
}
}
if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) &&
__instance.UseButton.isActiveAndEnabled)
{
KillButton.renderer.sprite = Main.replacedets.shieldIco;
KillButton.gameObject.SetActive(true);
KillButton.isActive = true;
KillButton.SetCoolDown(0f, 1f);
KillButton.SetTarget(target);
}
if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Officer) &&
__instance.UseButton.isActiveAndEnabled)
{
KillButton.gameObject.SetActive(true);
KillButton.isActive = true;
KillButton.SetCoolDown(PlayerTools.getOfficerCD(), PlayerControl.GameOptions.KillCooldown + 15.0f);
KillButton.SetTarget(target);
}
}
19
Source : Program.cs
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
public void PrintX() => Console.Write(x);
19
Source : Program.cs
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 15 == 0)
{
Write("FizzBuzz");
}
else if (i % 5 == 0)
{
Write("Buzz");
}
else if (i % 3 == 0)
{
Write("Fizz");
}
else
{
Write(i);
}
// put a comma and space after every number except 100
if (i < 100) Write(", ");
// write a carriage-return after every ten numbers
if (i % 10 == 0) WriteLine();
}
WriteLine();
}
19
Source : 4ThreadPool.cs
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
private static void PrintNumber10Times(object state)
{
for (int i = 0; i < 10; i++)
{
Console.Write(1);
}
Console.WriteLine();
}
19
Source : 1CreatingAndStartingTasks.cs
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
private static void PrintNumber10Times()
{
for (int i = 0; i < 10; i++)
{
Console.Write(1);
}
Console.WriteLine();
}
See More Examples