Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Fórum PS ➡ Converting a type (class category) to bool, implicitly ♦
//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; // in reply to the // PowerShell thread, in Technet forum: // http://bit.ly/2mQHgpU namespace Rextester { class Test{ public const string TEST="TEST"; public string[] Arr; public static implicit operator bool(Test t){ return t.Arr==null?false:(Array.FindIndex(t.Arr,s=>s==TEST)>=0); } } public class Program { public static void Main(string[] args) { Test t=new Test(); if(t)Console.WriteLine("True");else Console.WriteLine("False"); // False t.Arr=new[]{"Abc","ABC"}; if(t)Console.WriteLine("True");else Console.WriteLine("False"); // False t.Arr=new[]{"Abc","ABC","Test"}; if(t)Console.WriteLine("True");else Console.WriteLine("False"); // False // NOTICE: HERE, THE OUTPUT IS True t.Arr=new[]{"Abc","ABC",Test.TEST}; if(t)Console.WriteLine("True");else Console.WriteLine("False"); // True Console.WriteLine("\n\nHello, world!"); } } }
run
|
edit
|
history
|
help
0
ByRef
726
Problem: rstring
SKYIES
contraseña
insertion sort
axcc szxscd
Hash plus i minus
Sorting String Problem need help
Enumerable