Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Ternary Operator
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; // aljodav // http://rextester.com/users/376 namespace Rextester { public class Aa{ private string _a; public Aa(int i){_a=i.ToString("D10");} public static implicit operator string(Aa a){return a._a;} public static implicit operator Bb(Aa a){return new Bb(int.Parse(a._a));} public override string ToString(){return _a;} } public class Bb{ private int _b; public Bb(int i){_b=i;} public override string ToString(){return _b.ToString("D5");} } public class Program { public static void Main(string[] args) { Aa a1=new Aa(11), a2=new Aa(22); int z; Console.WriteLine(2 > 1 ? a1 : "-5"); // prints 11 w/ zeroes Console.WriteLine(2 > 1 ? a2 : new Bb(-6)); // prints 22 w/ zeroes Console.WriteLine(2 > 1 ? z=33 : -7); // prints 33 Console.WriteLine("----------"); Console.WriteLine(2 < 1 ? a1 : "-5"); // prints -5 Console.WriteLine(2 < 1 ? a2 : new Bb(-6)); // prints -6 w/ zeroes Console.WriteLine(2 < 1 ? z=33 : -7); // prints -7 Console.WriteLine("----------"); Console.WriteLine("# {0} # {1} # {2} #",a1,a2,new Bb(33)); } } }
run
|
edit
|
history
|
help
0
Calculator Test
learning1
Schrikkeljaar
random no generation array
My world
GeneGenerator
Computing Time Zone Different
valida fechas sura
Unary example
breadbank