System.Console.WriteLine(bool)

Here are the examples of the csharp api System.Console.WriteLine(bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

19 Source : QuestManager.cs
with GNU Affero General Public License v3.0
from ACEmulator

public bool HasQuestCompletes(string questName)
        {
            if (Debug) Console.WriteLine($"{Name}.QuestManager.HasQuestCompletes({questName})");

            if (!questName.Contains("@"))
                return HasQuest(questName);

            var pieces = questName.Split('@');
            if (pieces.Length != 2)
            {
                Console.WriteLine($"{Name}.QuestManager.HasQuestCompletes({questName}): error parsing quest name");
                return false;
            }
            var name = pieces[0];
            if (!Int32.TryParse(pieces[1], out var numCompletes))
            {
                Console.WriteLine($"{Name}.QuestManager.HasQuestCompletes({questName}): unknown quest format");
                return HasQuest(questName);
            }
            var quest = GetQuest(name);
            if (quest == null)
                return false;

            var success = quest.NumTimesCompleted == numCompletes;     // minimum or exact?
            if (Debug) Console.WriteLine(success);
            return success;
        }

19 Source : TriggerConfigMeta.cs
with MIT License
from aliyun

public override bool Equals(object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return false;
            }
            else
            {
                OSSTriggerFilter p = (OSSTriggerFilter)obj;
                Console.WriteLine(Key.Equals(p.Key));
                return Key.Equals(p.Key);
            }
        }

19 Source : Program.cs
with MIT License
from alsami

public static async Task Main(string[] _)
        {
            var ctx = new CancellationToken();
            var ctxs = CancellationTokenSource.CreateLinkedTokenSource(ctx);

            Console.CancelKeyPress += (x, y) =>
            {
                y.Cancel = true;
                ctxs.Cancel(false);
            };

            var builder = new ContainerBuilder();

            builder.RegisterMediatR(typeof(CustomerLoadQuery).replacedembly);

            builder.RegisterType<CustomersRepository>()
                .As<ICustomersRepository>()
                .SingleInstance();

            var container = builder.Build();

            var lifetimeScope = container.Resolve<ILifetimeScope>();

            var googleCustomerAddCommand = new CustomerAddCommand(Guid.NewGuid(), "google");

            await using (var scope = lifetimeScope.BeginLifetimeScope())
            {
                var mediator = scope.Resolve<IMediator>();

                await mediator.Send(googleCustomerAddCommand, ctx);
            }

            await using (var scope = lifetimeScope.BeginLifetimeScope())
            {
                var mediator = scope.Resolve<IMediator>();

                var customer = await mediator.Send(new CustomerLoadQuery(googleCustomerAddCommand.Id), ctx);

                Console.WriteLine(googleCustomerAddCommand.Name == customer.Name);

                try
                {
                    await mediator.Send(new CustomerLoadQuery(Guid.Empty), ctx);
                }
                catch (CustomerNotFoundException)
                {
                    Console.WriteLine("Expected that the customer could not be found bc we didn't add him b4.");
                }
            }

            Console.ReadKey();
        }

19 Source : RedisTest.cs
with MIT License
from aprilyush

public static void Test()
        {
            var redisHelper =new FullRedis("127.0.0.1:6379","", 1);
            redisHelper.Log = XTrace.Log;
            Console.WriteLine("共有缓存对象{0}个", redisHelper.Count);
            // 简单操作
            redisHelper.Set("name", "于硕",200);
            Console.WriteLine(redisHelper.Get<string>("name"));
            // 列表
            //var list = redisHelper.GetList<DateTime>("list");
            //list.Add(DateTime.Now);
            //list.Add(DateTime.Now.Date);
            //list.RemoveAt(1);
            //Console.WriteLine(list[list.Count - 1].ToFullString());

            // 字典
            var dic = redisHelper.GetDictionary<DateTime>("dic");
            //dic.Add("dic", DateTime.Now);
            //dic.Add("dic2", DateTime.Now.AddDays(1));
            //Console.WriteLine(dic["dic"].ToFullString());

            // 队列
            //var mq = redisHelper.GetQueue<String>("queue");
            //mq.Add(new[] { "abc", "g", "e", "m" });
            //var arr = mq.Take(3);
            //Console.WriteLine(arr.Join(","));


            // 集合
            var set = redisHelper.GetSet<String>("181110_1234");
            set.Add("xx1");
            set.Add("xx2");
            set.Add("xx3");
            Console.WriteLine(set.Count);
            Console.WriteLine(set.Contains("xx2"));
        }

19 Source : DetermineSpatialRelationViaRelateMethod.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineSpatialRelationViaRelateMethod
            var geometry1 = new LineString();
            geometry1.AddPoint(0, 0);
            geometry1.AddPoint(0, 2);

            var geometry2 = new LineString();
            geometry2.AddPoint(0, 1);
            geometry2.AddPoint(0, 3);

            // Relate method takes a string representation of DE-9IM matrix
            // (Dimensionally Extended Nine-Intersection Model matrix).
            // see Simple Feature Access specification for more details on DE-9IM.

            // this is the equivalent of 'geometry1.SpatiallyEquals(geometry2)'
            Console.WriteLine(geometry1.Relate(geometry2, "T*F**FFF*")); // False

            // this is the equivalent of 'geometry1.Disjoint(geometry2)'
            Console.WriteLine(geometry1.Relate(geometry2, "FF*FF****")); // False

            // this is the equivalent of 'geometry1.Overlaps(geometry2)'
            Console.WriteLine(geometry1.Relate(geometry2, "1*T***T**")); // True
            //ExEnd: DetermineSpatialRelationViaRelateMethod
        }

19 Source : DetermineIfOneGeometryCoversAnother.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfOneGeometryCoversAnother
            var line = new LineString();
            line.AddPoint(0, 0);
            line.AddPoint(1, 1);

            var point = new Point(0, 0);
            Console.WriteLine(line.Covers(point));    // True
            Console.WriteLine(point.CoveredBy(line)); // True
            //ExEnd: DetermineIfOneGeometryCoversAnother
        }

19 Source : GetGeometryBuffer.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: GetGeometryBuffer
            var line = new LineString();
            line.AddPoint(0, 0);
            line.AddPoint(3, 3);

            // buffer with positive distance contains all points whose distance to input geometry is less or equal to 'distance' argument.
            var lineBuffer = line.GetBuffer(distance: 1);

            Console.WriteLine(lineBuffer.SpatiallyContains(new Point(1, 2)));     // True
            Console.WriteLine(lineBuffer.SpatiallyContains(new Point(3.1, 3.1))); // True

            var polygon = new Polygon();
            polygon.ExteriorRing = new LinearRing(new[]
            {
                new Point(0, 0),
                new Point(0, 3),
                new Point(3, 3),
                new Point(3, 0),
                new Point(0, 0),
            });

            // buffer with negative distance 'shrinks' geometry.
            var polygonBuffer = (IPolygon)polygon.GetBuffer(distance: -1);

            // [0] = (1 1)
            // [1] = (1 2)
            // [2] = (2 2)
            // [3] = (2 1)
            // [4] = (1 1)
            var ring = polygonBuffer.ExteriorRing;
            for (int i = 0; i < ring.Count; ++i)
            {
                Console.WriteLine("[{0}] = ({1} {2})", i, ring[i].X, ring[i].Y);
            }
            //ExEnd: GetGeometryBuffer
        }

19 Source : GetPointOnSurface.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: GetPointOnSurface
            var polygon = new Polygon();
            polygon.ExteriorRing = new LinearRing(new[]
            {
                new Point(0, 0),
                new Point(0, 1),
                new Point(1, 1),
                new Point(0, 0),
            });

            IPoint pointOnSurface = polygon.GetPointOnSurface();

            // point on surface is guaranteed to be inside a polygon.
            Console.WriteLine(polygon.SpatiallyContains(pointOnSurface)); // True
            //ExEnd: GetPointOnSurface
        }

19 Source : RemoveLayersFromFileGdbDataset.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: RemoveLayersFromFileGdbDataset
            // -- copy test dataset, to avoid modification of test data.

            //var datasetPath = GetOutputPath(".gdb");
            var path = RunExamples.GetDataDir() + "ThreeLayers.gdb";
            var datasetPath = RunExamples.GetDataDir() + "RemoveLayersFromFileGdbDataset_out.gdb";
            RunExamples.CopyDirectory(path, datasetPath);

            // --

            using (var dataset = Dataset.Open(datasetPath, Drivers.FileGdb))
            {
                Console.WriteLine(dataset.CanRemoveLayers); // True

                Console.WriteLine(dataset.LayersCount); // 3

                // remove layer by index
                dataset.RemoveLayerAt(2);
                Console.WriteLine(dataset.LayersCount); // 2

                // remove layer by name
                dataset.RemoveLayer("layer1");
                Console.WriteLine(dataset.LayersCount); // 1
            }
            //ExEnd: RemoveLayersFromFileGdbDataset
        }

19 Source : DetermineIfGeometriesAreSpatiallyEqual.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometriesAreSpatiallyEqual
            var geometry1 = new MultiLineString
            {
                new LineString(new [] { new Point(0, 0), new Point(1, 1) }),
                new LineString(new [] { new Point(1, 1), new Point(2, 2) }),
            };

            var geometry2 = new LineString(new[]
            {
                new Point(0, 0), new Point(2, 2),
            });

            Console.WriteLine(geometry1.SpatiallyEquals(geometry2)); // True

            geometry2.AddPoint(3, 3);
            Console.WriteLine(geometry1.SpatiallyEquals(geometry2)); // False
            //ExEnd: DetermineIfGeometriesAreSpatiallyEqual
        }

19 Source : DetermineIfGeometriesCrossEachOther.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometriesCrossEachOther
            var geometry1 = new LineString();
            geometry1.AddPoint(0, 0);
            geometry1.AddPoint(2, 2);

            var geometry2 = new LineString();
            geometry2.AddPoint(1, 1);
            geometry2.AddPoint(3, 3);

            Console.WriteLine(geometry1.Crosses(geometry2)); // False

            var geometry3 = new LineString();
            geometry3.AddPoint(0, 2);
            geometry3.AddPoint(2, 0);

            Console.WriteLine(geometry1.Crosses(geometry3)); // True
            //ExEnd: DetermineIfGeometriesCrossEachOther
        }

19 Source : DetermineIfGeometriesIntersect.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometriesIntersect
            var geometry1 = new Polygon(new LinearRing(new[]
            {
                new Point(0, 0),
                new Point(0, 3),
                new Point(3, 3),
                new Point(3, 0),
                new Point(0, 0),
            }));

            var geometry2 = new Polygon(new LinearRing(new[]
            {
                new Point(1, 1),
                new Point(1, 4),
                new Point(4, 4),
                new Point(4, 1),
                new Point(1, 1),
            }));

            Console.WriteLine(geometry1.Intersects(geometry2)); // True
            Console.WriteLine(geometry2.Intersects(geometry1)); // True

            // 'Disjoint' is opposite to 'Intersects'
            Console.WriteLine(geometry1.Disjoint(geometry2)); // False
            //ExEnd: DetermineIfGeometriesIntersect
        }

19 Source : DetermineIfGeometriesOverlap.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometriesOverlap
            var geometry1 = new LineString();
            geometry1.AddPoint(0, 0);
            geometry1.AddPoint(0, 2);

            var geometry2 = new LineString();
            geometry2.AddPoint(0, 2);
            geometry2.AddPoint(0, 3);

            Console.WriteLine(geometry1.Overlaps(geometry2)); // False

            var geometry3 = new LineString();
            geometry3.AddPoint(0, 1);
            geometry3.AddPoint(0, 3);

            Console.WriteLine(geometry1.Overlaps(geometry3)); // True
            //ExEnd: DetermineIfGeometriesOverlap
        }

19 Source : DetermineIfGeometriesTouchEachOther.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometriesTouchEachOther
            var geometry1 = new LineString();
            geometry1.AddPoint(0, 0);
            geometry1.AddPoint(2, 2);

            var geometry2 = new LineString();
            geometry2.AddPoint(2, 2);
            geometry2.AddPoint(3, 3);

            Console.WriteLine(geometry1.Touches(geometry2)); // True
            Console.WriteLine(geometry2.Touches(geometry1)); // True

            var geometry3 = new Point(2, 2);
            Console.WriteLine(geometry1.Touches(geometry3)); // True

            var geometry4 = new LineString();
            geometry4.AddPoint(1, 1);
            geometry4.AddPoint(4, 4);

            Console.WriteLine(geometry1.Touches(geometry4)); // False
            //ExEnd: DetermineIfGeometriesTouchEachOther
        }

19 Source : DetermineIfGeometryHasCurves.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfGeometryHasCurves
            var geometryWithoutCurves = Geometry.FromText(@"GeometryCollection (LineString (0 0, 1 1, 2 0),CompoundCurve ((4 0, 5 1), (5 1, 6 2, 7 1)))");
            // geometry does not contain circular string, so HasCurveGeometry returns false.
            Console.WriteLine(geometryWithoutCurves.HasCurveGeometry); // False

            var geometry = Geometry.FromText(@"GeometryCollection (LineString (0 0, 1 1, 2 0),CompoundCurve ((4 0, 5 1), CircularString (5 1, 6 2, 7 1)))");
            // geometry contains circular string, so HasCurveGeometry returns true.
            Console.WriteLine(geometry.HasCurveGeometry); // True
            //ExEnd: DetermineIfGeometryHasCurves
        }

19 Source : DetermineIfOneGeometryContainsAnother.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: DetermineIfOneGeometryContainsAnother
            var geometry1 = new Polygon();
            geometry1.ExteriorRing = new LinearRing(new[]
            {
                new Point(0, 0),
                new Point(0, 4),
                new Point(4, 4),
                new Point(4, 0),
                new Point(0, 0),
            });
            geometry1.AddInteriorRing(new LinearRing(new[]
            {
                new Point(1, 1),
                new Point(1, 3),
                new Point(3, 3),
                new Point(3, 1),
                new Point(1, 1),
            }));

            var geometry2 = new Point(2, 2);

            Console.WriteLine(geometry1.SpatiallyContains(geometry2)); // False

            var geometry3 = new Point(0.5, 0.5);
            Console.WriteLine(geometry1.SpatiallyContains(geometry3)); // True

            // 'a.SpatiallyContains(b)' equals to 'b.Within(a)'
            Console.WriteLine(geometry3.Within(geometry1)); // True
            //ExEnd: DetermineIfOneGeometryContainsAnother
        }

19 Source : AddLayerToFileGdbDataset.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: AddLayerToFileGdbDataset
            // -- copy test dataset, to avoid modification of test data.

            var path = RunExamples.GetDataDir() + "ThreeLayers.gdb";
            var datasetPath = RunExamples.GetDataDir() + "AddLayerToFileGdbDataset_out.gdb";
            RunExamples.CopyDirectory(path, datasetPath);

            // --

            using (var dataset = Dataset.Open(datasetPath, Drivers.FileGdb))
            {
                Console.WriteLine(dataset.CanCreateLayers); // True

                using (var layer = dataset.CreateLayer("data", SpatialReferenceSystem.Wgs84))
                {
                    layer.Attributes.Add(new FeatureAttribute("Name", AttributeDataType.String));
                    var feature = layer.ConstructFeature();
                    feature.SetValue("Name", "Name_1");
                    feature.Geometry = new Point(12.21, 23.123, 20, -200);
                    layer.Add(feature);
                }

                using (var layer = dataset.OpenLayer("data"))
                {
                    Console.WriteLine(layer.Count); // 1
                    Console.WriteLine(layer[0].GetValue<string>("Name")); // "Name_1"
                }
            }
            //ExEnd: AddLayerToFileGdbDataset
        }

19 Source : CreateFileGdbDataset.cs
with MIT License
from aspose-gis

public static void Run()
        {
            //ExStart: CreateFileGdbDataset
            Console.WriteLine(Drivers.FileGdb.CanCreateDatasets); // True
            var path = RunExamples.GetDataDir() + "CreateFileGdbDataset_out.gdb";

            using (var dataset = Dataset.Create(path, Drivers.FileGdb))
            {
                Console.WriteLine(dataset.LayersCount); // 0

                using (var layer = dataset.CreateLayer("layer_1"))
                {
                    layer.Attributes.Add(new FeatureAttribute("value", AttributeDataType.Integer));

                    for (int i = 0; i < 10; ++i)
                    {
                        var feature = layer.ConstructFeature();
                        feature.SetValue("value", i);
                        feature.Geometry = new Point(i, i);
                        layer.Add(feature);
                    }
                }

                using (var layer = dataset.CreateLayer("layer_2"))
                {
                    var feature = layer.ConstructFeature();
                    feature.Geometry = new LineString(new[]
                    {
                        new Point(1, 2),
                        new Point(3, 4),
                    });
                    layer.Add(feature);
                }

                Console.WriteLine(dataset.LayersCount); // 2
            }
            //ExEnd: CreateFileGdbDataset
        }

19 Source : GetBookmarks.cs
with MIT License
from aspose-pdf

public static void Run()
        {
            // ExStart:GetBookmarks
            // The path to the doreplacedents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Bookmarks();

            // Open doreplacedent
            Doreplacedent pdfDoreplacedent = new Doreplacedent(dataDir + "GetBookmarks.pdf");

            // Loop through all the bookmarks
            foreach (OutlineItemCollection outlineItem in pdfDoreplacedent.Outlines)
            {
                Console.WriteLine(outlineItem.replacedle);
                Console.WriteLine(outlineItem.Italic);
                Console.WriteLine(outlineItem.Bold);
                Console.WriteLine(outlineItem.Color);
            }
            // ExEnd:GetBookmarks
        }

19 Source : GetChildBookmarks.cs
with MIT License
from aspose-pdf

public static void Run()
        {
            // ExStart:GetChildBookmarks
            // The path to the doreplacedents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Bookmarks();

            // Open doreplacedent
            Doreplacedent pdfDoreplacedent = new Doreplacedent(dataDir + "GetChildBookmarks.pdf");

            // Loop through all the bookmarks
            foreach (OutlineItemCollection outlineItem in pdfDoreplacedent.Outlines)
            {
                Console.WriteLine(outlineItem.replacedle);
                Console.WriteLine(outlineItem.Italic);
                Console.WriteLine(outlineItem.Bold);
                Console.WriteLine(outlineItem.Color);

                if (outlineItem.Count > 0)
                {
                    Console.WriteLine("Child Bookmarks");
                    // There are child bookmarks then loop through that as well
                    foreach (OutlineItemCollection childOutline in outlineItem)
                    {
                        Console.WriteLine(childOutline.replacedle);
                        Console.WriteLine(childOutline.Italic);
                        Console.WriteLine(childOutline.Bold);
                        Console.WriteLine(childOutline.Color);
                    }
                }
            }
            // ExEnd:GetChildBookmarks
        }

19 Source : Exemplo9.3.cs
with MIT License
from atrigo

static void Main(string[] args)
        {
            string frase1 = "C#";
            string frase2 = "C#";
            string frase3 = "c#";
            Console.WriteLine(frase1.Equals("C#")); //True
            Console.WriteLine(frase1.Equals(frase2)); //True
            Console.WriteLine(frase1.Equals(frase3)); //False
            Console.WriteLine(frase1 == "C#"); //True
            Console.WriteLine(frase1 == frase2); //True
            Console.WriteLine(frase1 == frase3); //False
        }

19 Source : Exemplo5.1.cs
with MIT License
from atrigo

static void Main(string[] args)
        {
            int peso = 80;
            char genero = 'M';
            Console.WriteLine(peso == 80); //True
            Console.WriteLine(peso >= 80); //True		
            Console.WriteLine(genero == 'F'); //False		
            Console.WriteLine(genero > 'F'); //True
            Console.WriteLine((2 * 3 > 4) != (5 < 2)); //True              
        }

19 Source : Exemplo5.2.cs
with MIT License
from atrigo

static void Main(string[] args)
        {
            Console.WriteLine(4 > 5); //False
            Console.WriteLine(4 < 5 && 6 > 10); //False		
            Console.WriteLine(40 < 50 || 60 > 90); //True		
            Console.WriteLine(!(40 < 50 || 60 > 90)); //False           
        }

19 Source : Exemplo5.3.cs
with MIT License
from atrigo

static void Main(string[] args)
        {
            Console.WriteLine(5 + 3 * 9); //32
            Console.WriteLine((5 + 3) * 9); //72		
            Console.WriteLine(!false || true); //True (negacao avaliada antes do OU)		
            Console.WriteLine(!(false || true)); //False (OU avaliado antes da negacao)
            Console.WriteLine(true || false && false); //True (E avaliadao antes do OU)
            Console.WriteLine((true || false) && false); //False       
        }

19 Source : TokenManipulation.cs
with BSD 3-Clause "New" or "Revised" License
from b4rtik

public static void Execute(string[] args)
    {
        string binarytorun;
        string binarypath;
        string binaryarguments;
        if (string.IsNullOrEmpty(binary))
        {
            binarytorun = spawn;
            binarypath = @"C:\WINDOWS\System32\";
            binaryarguments = string.Empty;
        }
        else
        {
            binarytorun = binary;
            binarypath = path;
            binaryarguments = arguments;
        }


        Console.WriteLine(BypreplacedUAC(binarytorun, binarypath, binaryarguments));
    }

19 Source : MemoryModelDeadlock.cs
with MIT License
from badamczewski

public void Spin()
        {
            bool taken = false;
            for (int i = 0; i < 1000; i++)
            {
                taken = false;
                     
                spinLock.Enter(ref taken);
                {
                    int d = 0;
                    for (int k = 0; k < 1000000; k++)
                        d++;
                }
                spinLock.Exit(true);

                if (taken == false)
                    Console.WriteLine(taken);
            }
        }

19 Source : ConsoleOutput.cs
with MIT License
from bartoszgolek

public void WriteLine(bool value)
        {
            Console.WriteLine(value);
        }

19 Source : Solution.cs
with MIT License
from cwetanow

public static void Test()
		{
			var numbers = Console.ReadLine()
				.Split(' ')
				.Select(int.Parse)
				.ToList();

			var k = int.Parse(Console.ReadLine());

			var result = TwoNumbersEqual(numbers, k);
			Console.WriteLine(result);
		}

19 Source : Program.cs
with GNU General Public License v3.0
from Decimation

private static void Main(string[] args)
		{
			// ...
			Console.WriteLine(Environment.Version);
			var ss = Global.Clr.Scanner.Value;
			var a  = ss.FindSignature("48 8B 41 28 A8 02 74 ? 48 8B 40 26 C3");
			Console.WriteLine(a);

			int          i  = 256;

			Pointer<int> px = &i;

			var pointer = SigScanner.ScanProcess("48 8B 41 28 A8 02 74 ? 48 8B 40 26 C3").FirstOrDefault();

			Console.WriteLine(pointer);

			Console.WriteLine(a == pointer);
		}

19 Source : UnitTest1.cs
with GNU Affero General Public License v3.0
from EKarton

[TestMethod]
        public void TestMethod1()
        {
            //BuildingDistanceCalculator calculator = new BuildingDistanceCalculator();
            //BuildingDistance distance = calculator.GetInfoBetweenBuildings("walking", "Queens Park, Toronto, ON", "Bahen");
            Tuple<string, string> tuple1 = new Tuple<string, string>("wasd", "wasddd");
            Dictionary<Tuple<string, string>, int> dictionary = new Dictionary<Tuple<string, string>, int>();
            dictionary.Add(tuple1, 12);

            Tuple<string, string> tuple2 = new Tuple<string, string>("wasd", "wasddd");
            Console.WriteLine(dictionary.ContainsKey(tuple2));
            Console.WriteLine(dictionary[tuple2]);
        }

19 Source : HomeController.cs
with Apache License 2.0
from elastic

public async Task<IActionResult> FailingOutGoingHttpCall()
		{
			var client = new HttpClient();
			var result = await client.GetAsync("http://dsfklgjdfgkdfg.mmmm");
			Console.WriteLine(result.IsSuccessStatusCode);

			return Ok();
		}

19 Source : HomeController.cs
with Apache License 2.0
from elastic

public async Task<ActionResult> ThrowsNameCouldNotBeResolved()
		{
			var result = await new HttpClient().GetAsync("http://dsfklgjdfgkdfg.mmmm");
			Console.WriteLine(result.IsSuccessStatusCode);
			return null;
		}

19 Source : DictionaryExtensionTests.cs
with GNU General Public License v3.0
from faib920

[TestMethod]
        public void TestTryGetValue()
        {
            var dict = new Dictionary<string, string> { { "1", "abc" }, { "2", "def" } };

            Console.WriteLine(dict.TryGetValue("1", () => "abc_1"));
            Console.WriteLine(dict.TryGetValue("3", () => "ghi_1"));
        }

19 Source : ReflectionExtensionTests.cs
with GNU General Public License v3.0
from faib920

[TestMethod()]
        public void IsDefinedTest()
        {
            Console.WriteLine(MethodBase.GetCurrentMethod().IsDefined<TestMethodAttribute>());
        }

19 Source : ContainerTests.cs
with GNU General Public License v3.0
from faib920

[TestMethod()]
        public void RegisterSingletonTest()
        {
            var key = MethodBase.GetCurrentMethod().Name;
            var container = ContainerUnity.GetContainer(key);

            container.Register<IMainService>(() => new MainService());

            //第一次反转
            var obj1 = container.Resolve<IMainService>();

            //再次反转
            var obj2 = container.Resolve<IMainService>();
            Console.WriteLine(obj1 == obj2);
        }

19 Source : Lambda.cs
with MIT License
from GeorgeAlexandria

public void Create()
        {
            Func<int, bool> isNegative = (int arg) => arg < 0;
            // Check argument usage in a ParenthesizedLambdaExpression
            Func<int, bool> isPositive = (int arg) => { return arg < 0; };

            Console.WriteLine(isNegative(25));
            Console.WriteLine(isPositive(25));
        }

19 Source : LocalMethod.cs
with MIT License
from GeorgeAlexandria

public void Create()
        {
            bool IsPositive(int arg) => arg > 0;

            Console.WriteLine(IsPositive(25));
            Console.WriteLine(IsPositive(-25));
        }

19 Source : Delegate.cs
with MIT License
from GeorgeAlexandria

public void Create()
        {
            Func<int, bool> isPositive = delegate (int arg)
            {
                return arg > 0;
            };
            Console.WriteLine(isPositive(25));
        }

19 Source : method-contain.cs
with MIT License
from gungunfebrianza

static void Main(string[] args)
  {
    // Creating a Queue 
    Queue myQueue = new Queue();

    // Inserting the elements into the Queue 
    myQueue.Enqueue(5);
    myQueue.Enqueue(10);
    myQueue.Enqueue(15);
    myQueue.Enqueue(20);
    myQueue.Enqueue(25);

    // Checking whether the element is 
    // present in the Queue or not 
    // The function returns True if the 
    // element is present in the Queue, else 
    // returns False 
    Console.WriteLine(myQueue.Contains(7));
  }

19 Source : ComparerPatterns.cs
with BSD 3-Clause "New" or "Revised" License
from HalcyonGrid

public static void Main(String[] args) {
    SCG.IComparer<Rec<string,int>> lexico1 = new Lexico();
    SCG.IComparer<Rec<string,int>> lexico2 =
      new DelegateComparer<Rec<string,int>>(
          delegate(Rec<string,int> item1, Rec<string,int> item2) { 
            int major = item1.X1.CompareTo(item2.X1);
            return major != 0 ? major : item1.X2.CompareTo(item2.X2);
          });
    Rec<String,int> r1 = new Rec<String,int>("Carsten", 1962);
    Rec<String,int> r2 = new Rec<String,int>("Carsten", 1964);
    Rec<String,int> r3 = new Rec<String,int>("Christian", 1932);
    Console.WriteLine(lexico1.Compare(r1, r1) == 0);
    Console.WriteLine(lexico1.Compare(r1, r2) < 0);
    Console.WriteLine(lexico1.Compare(r2, r3) < 0);
    Console.WriteLine(lexico2.Compare(r1, r1) == 0);
    Console.WriteLine(lexico2.Compare(r1, r2) < 0);
    Console.WriteLine(lexico2.Compare(r2, r3) < 0);
    
    SCG.IComparer<String> rev 
      = ReverseComparer<String>(Comparer<String>.Default);
    Console.WriteLine(rev.Compare("A", "A") == 0);
    Console.WriteLine(rev.Compare("A", "B") > 0);
    Console.WriteLine(rev.Compare("B", "A") < 0);
  }

19 Source : SerializationExample.cs
with BSD 3-Clause "New" or "Revised" License
from HalcyonGrid

public static void Main() {
      IList<String> names = new LinkedList<String>();
      String reagan = "Reagan";
      names.AddAll(new String[] { reagan, reagan, "Bush", "Clinton", 
                                  "Clinton", "Bush", "Bush" });
      ToFile(names, "prez.bin");
      IList<String> namesFromFile = FromFile<IList<String>>("prez.bin");

      foreach (String s in namesFromFile) 
        Console.WriteLine(s);

      Console.Write("Deserialization preserves sequenced equality: ");
      Console.WriteLine(names.SequencedEquals(namesFromFile));
      Console.Write("Deserialization reuses the same strings: ");
      Console.WriteLine(Object.ReferenceEquals(reagan, namesFromFile[1]));
      Console.Write("Deserialization preserves sharing: ");
      Console.WriteLine(Object.ReferenceEquals(namesFromFile[0], namesFromFile[1]));
    }

19 Source : Program.cs
with MIT License
from head-first-csharp

static void Main(string[] args)
        {
            Guy joe1 = new Guy("Joe", 37, 100);
            Guy joe2 = joe1;
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // True
            Console.WriteLine(joe1.Equals(joe2));                  // True
            Console.WriteLine(Object.ReferenceEquals(null, null)); // True

            joe2 = new Guy("Joe", 37, 100);
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // False
            Console.WriteLine(joe1.Equals(joe2));                  // False

            joe1 = new EquatableGuy("Joe", 37, 100);
            joe2 = new EquatableGuy("Joe", 37, 100);
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // False
            Console.WriteLine(joe1.Equals(joe2));                  // True

            joe1.GiveCash(50);
            Console.WriteLine(joe1.Equals(joe2));                  // False
            joe2.GiveCash(50);
            Console.WriteLine(joe1.Equals(joe2));                  // True

            List<Guy> guys = new List<Guy>() {
                new Guy("Bob", 42, 125),
                new EquatableGuy(joe1.Name, joe1.Age, joe1.Cash),
                new Guy("Ed", 39, 95)
            };
            Console.WriteLine(guys.Contains(joe1));                // True
            Console.WriteLine(joe1 == joe2);                       // False


            joe1 = new EquatableGuyWithOverload(joe1.Name, joe1.Age, joe1.Cash);
            joe2 = new EquatableGuyWithOverload(joe1.Name, joe1.Age, joe1.Cash);
            Console.WriteLine(joe1 == joe2); // False
            Console.WriteLine(joe1 != joe2); // True
            Console.WriteLine((EquatableGuyWithOverload)joe1 == (EquatableGuyWithOverload)joe2); // True
            Console.WriteLine((EquatableGuyWithOverload)joe1 != (EquatableGuyWithOverload)joe2); // False
            joe2.ReceiveCash(25);
            Console.WriteLine((EquatableGuyWithOverload)joe1 == (EquatableGuyWithOverload)joe2); // False
            Console.WriteLine((EquatableGuyWithOverload)joe1 != (EquatableGuyWithOverload)joe2); // True

            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from head-first-csharp

static void Main(string[] args)
        {
            Card cardToCheck = new Card(Suits.Clubs, Values.Three);
            bool doesItMatch = Card.DoesCardMatch(cardToCheck, Suits.Hearts);
            Console.WriteLine(doesItMatch);
        }

19 Source : Program.cs
with MIT License
from head-first-csharp

static void Main(string[] args)
        {
            /*
            * In Chapter 15, you saw how the var keyword let the IDE determine the
            * type of an object at compile time.
            *
            * You can also create objects with anonymous types using var and new.
            *
            * You can learn more about anonymous types here:
            * http://msdn.microsoft.com/en-us/library/bb397696.aspx
            */
            // Create an anonymous type that looks a lot like a guy:
            var anonymousGuy = new { Name = "Bob", Age = 43, Cash = 137 };
            // When you type this in, the IDE’s IntelliSense automatically picks up
            // the members -- Name, Age and Cash show up in the IntelliSense window.
            Console.WriteLine("{0} is {1} years old and has {2} bucks",
            anonymousGuy.Name, anonymousGuy.Age, anonymousGuy.Cash);
            // Output: Bob is 43 years old and has 137 bucks
            // An instance of an anonymous type has a sensible ToString() method.
            Console.WriteLine(anonymousGuy.ToString());
            // Output: { Name = Bob, Age = 43, Cash = 137 }
            /*
            * In Chapter 11, you learned about how you can use a delegate to reference
            * a method. In all of the examples of delegates that you’ve seen so far,
            * you replacedigned an existing method to a delegate.
            *
            * Anonymous methods are methods that you declare in a statement -- you
            * declare them using curly brackets { }, just like with anonymous types.
            *
            * You can learn more about anonymous methods here:
            * http://msdn.microsoft.com/en-us/library/0yw3tz5k.aspx
            */

            // Here’s an anonymous method that writes an int and a string to the console.
            // Its declaration matches our MyIntAndString delegate (defined above), so
            // we can replacedign it to a variable of type MyIntAndString.
            MyIntAndString printThem = delegate(int i, string s)
            { Console.WriteLine("{0} - {1}", i, s); };
            printThem(123, "four five six");
            // Output: 123 - four five six
            // Here’s another anonymous method with the same signature (int, string).
            // This one checks if the string contains the int.
            MyIntAndString contains = delegate(int i, string s)
            { Console.WriteLine(s.Contains(i.ToString())); };
            contains(123, "four five six");
            // Output: False
            contains(123, "four 123 five six");
            // Output: True
            // You can dynamically invoke a method using Delegate.DynamicInvoke(),
            // preplaceding the parameters to the method as an array of objects.
            Delegate d = contains;
            d.DynamicInvoke(new object[] { 123, "four 123 five six" });
            // Output: True
            /*
            * A lambda expression is a special kind of anonymous method that uses
            * the => operator. It’s called the lambda operator, but when you’re
            * talking about lambda expressions you usually say "goes to" when
            * you read it. Here’s a simple lambda expression:
            *
            * (a, b) => { return a + b; }
            *
            * You could read that as "a and b goes to a plus b" -- it’s an anonymous
            * method for adding two values. You can think of lambda expressions as
            * anonymous methods that take parameters and can return values.
            *
            * You can learn more about lambda expressions here:
            * http://msdn.microsoft.com/en-us/library/bb397687.aspx
            */
            // Here’s that lambda expression for adding two numbers. Its signature
            // matches our CombineTwoInts delegate, so we can replacedign it to a delegate
            // variable of type CombineTwoInts. Notice how CombineTwoInts’s return
            // type is int -- that means the lambda expression needs to return an int.
            CombineTwoInts adder = (a, b) => { return a + b; };
            Console.WriteLine(adder(3, 5));
            // Output: 8
            // Here’s another lambda expression -- this one multiplies two numbers.
            CombineTwoInts multiplier = (int a, int b) => { return a * b; };
            Console.WriteLine(multiplier(3, 5));
            // Output: 15
            // You can do some seriously powerful stuff when you combine lambda
            // expressions with LINQ. Here’s a really simple example:
            var greaterThan3 = new List<int> { 1, 2, 3, 4, 5, 6 }.Where(x => x > 3);
            foreach (int i in greaterThan3) Console.Write("{0} ", i);
            // Output: 4 5 6
            Console.ReadKey();
        }

19 Source : Program.cs
with MIT License
from head-first-csharp

static void Main(string[] args)
        {
            Guy joe1 = new Guy("Joe", 37, 100);
            Guy joe2 = joe1;
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // True
            Console.WriteLine(joe1.Equals(joe2));                  // True
            Console.WriteLine(Object.ReferenceEquals(null, null)); // True

            joe2 = new Guy("Joe", 37, 100);
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // False
            Console.WriteLine(joe1.Equals(joe2));                  // False

            joe1 = new EquatableGuy("Joe", 37, 100);
            joe2 = new EquatableGuy("Joe", 37, 100);
            Console.WriteLine(Object.ReferenceEquals(joe1, joe2)); // False
            Console.WriteLine(joe1.Equals(joe2));                  // True

            joe1.GiveCash(50);
            Console.WriteLine(joe1.Equals(joe2));                  // False
            joe2.GiveCash(50);
            Console.WriteLine(joe1.Equals(joe2));                  // True

            List<Guy> guys = new List<Guy>() {
                new Guy("Bob", 42, 125),
                new EquatableGuy(joe1.Name, joe1.Age, joe1.Cash),
                new Guy("Ed", 39, 95)
            };
            Console.WriteLine(guys.Contains(joe1));                // True
            Console.WriteLine(joe1 == joe2);                       // False


            joe1 = new EquatableGuyWithOverload(joe1.Name, joe1.Age, joe1.Cash);
            joe2 = new EquatableGuyWithOverload(joe1.Name, joe1.Age, joe1.Cash);
            Console.WriteLine(joe1 == joe2); // False
            Console.WriteLine(joe1 != joe2); // True
            Console.WriteLine((EquatableGuyWithOverload)joe1 == (EquatableGuyWithOverload)joe2); // True
            Console.WriteLine((EquatableGuyWithOverload)joe1 != (EquatableGuyWithOverload)joe2); // False
            joe2.ReceiveCash(25);
            Console.WriteLine((EquatableGuyWithOverload)joe1 == (EquatableGuyWithOverload)joe2); // False
            Console.WriteLine((EquatableGuyWithOverload)joe1 != (EquatableGuyWithOverload)joe2); // True

            Console.ReadKey();

        }

19 Source : Program.cs
with MIT License
from head-first-csharp

static void Main(string[] args)
        {
            /*
             * In Chapter 14, you saw how the var keyword let the IDE determine the
             * type of an object at compile time.  
             * 
             * You can also create objects with anonymous types using var and new.
             * 
             * You can learn more about anonymous types here:
             * http://msdn.microsoft.com/en-us/library/bb397696.aspx
             */

            // Create an anonymous type that looks a lot like a guy:
            var anonymousGuy = new { Name = "Bob", Age = 43, Cash = 137 };

            // When you type this in, the IDE’s IntelliSense automatically picks up
            // the members -- Name, Age and Cash show up in the IntelliSense window.
            Console.WriteLine("{0} is {1} years old and has {2} bucks",
                anonymousGuy.Name, anonymousGuy.Age, anonymousGuy.Cash);
            // Output: Bob is 43 years old and has 137 bucks

            // An instance of an anonymous type has a sensible ToString() method.
            Console.WriteLine(anonymousGuy.ToString());
            // Output: { Name = Bob, Age = 43, Cash = 137 }

            /*
             * In Chapter 15, you learned about how you can use a delegate to reference 
             * a method. In all of the examples of delegates that you've seen so far,
             * you replacedigned an existing method to a delegate. 
             * 
             * Anonymous methods are methods that you declare in a statement -- you
             * declare them using curly brackets { }, just like with anonymous types.
             * 
             * You can learn more about anonymous methods here:
             * http://msdn.microsoft.com/en-us/library/0yw3tz5k.aspx
             */

            // Here’s an anonymous method that writes an int and a string to the console.
            // Its declaration matches our MyIntAndString delegate (defined above), so
            // we can replacedign it to a variable of type MyIntAndString.
            MyIntAndString printThem = delegate(int i, string s)
            { Console.WriteLine("{0} - {1}", i, s); };
            printThem(123, "four five six");
            // Output: 123 - four five six

            // Here’s another anonymous method with the same signature (int, string). 
            // This one checks if the string contains the int.
            MyIntAndString contains = delegate(int i, string s)
            { Console.WriteLine(s.Contains(i.ToString())); };
            contains(123, "four five six");
            // Output: False

            contains(123, "four 123 five six");
            // Output: True

            // You can dynamically invoke a method using Delegate.DynamicInvoke(),
            // preplaceding the parameters to the method as an array of objects.
            Delegate d = contains;
            d.DynamicInvoke(new object[] { 123, "four 123 five six" });
            // Output: True

            /*
             * A lambda expression is a special kind of anonymous method that uses 
             * the => operator. It's called the lambda operator, but when you're
             * talking about lambda expressions you usually say "goes to" when 
             * you read it. Here's a simple lambda expression:
             * 
             *    (a, b) => { return a + b; }
             * 
             * You could read that as "a and b goes to a plus b" -- it's an anonymous
             * method for adding two values. You can think of lambda expressions as
             * anonymous methods that take parameters and can return values.
             * 
             * You can learn more about lambda expressions here:
             * http://msdn.microsoft.com/en-us/library/bb397687.aspx
             */

            // Here’s that lambda expression for adding two numbers. Its signature
            // matches our CombineTwoInts delegate, so we can replacedign it to a delegate
            // variable of type CombineTwoInts. Notice how CombineTwoInts’s return
            // type is int -- that means the lambda expression needs to return an int.
            CombineTwoInts adder = (a, b) => { return a + b; };
            Console.WriteLine(adder(3, 5));
            // Output: 8

            // Here's another lambda expression -- this one multiplies two numbers.
            CombineTwoInts multiplier = (int a, int b) => { return a * b; };
            Console.WriteLine(multiplier(3, 5));
            // Output: 15

            // You can do some seriously powerful stuff when you combine lambda 
            // expressions with LINQ. Here’s a really simple example:
            var greaterThan3 = new List<int> { 1, 2, 3, 4, 5, 6 }.Where(x => x > 3);
            foreach (int i in greaterThan3) Console.Write("{0} ", i);
            // Output: 4 5 6 

            Console.ReadKey();
        }

19 Source : TestCommandHandler.cs
with Apache License 2.0
from horse-framework

protected override async Task Execute(SampleTestCommand command, HorseClient client)
		{
			using HorseTransaction transaction = new(client, "test");
			await transaction.Begin(new TestTransactionModel { Foo = transaction.Id });
			bool commited = await transaction.Commit();
			Console.WriteLine(commited);
		}

19 Source : SoftBasicExample.cs
with GNU Lesser General Public License v3.0
from HslCommunication-Community

public void IsTwoBytesEquelExample1( )
        {
            #region IsTwoBytesEquelExample1

            byte[] b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 };
            byte[] b2 = new byte[] { 0x12, 0xC6, 0x25, 0x3C, 0x42, 0x85, 0x5B, 0x05, 0x12, 0x87 };

            Console.WriteLine( SoftBasic.IsTwoBytesEquel( b1, 3, b2, 5, 4 ) );

            // 输出 true


            #endregion
        }

19 Source : SoftBasicExample.cs
with GNU Lesser General Public License v3.0
from HslCommunication-Community

public void IsTwoBytesEquelExample2( )
        {
            #region IsTwoBytesEquelExample2


            byte[] b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 };
            byte[] b2 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 };

            Console.WriteLine( SoftBasic.IsTwoBytesEquel( b1, b2 ) );

            // 输出 true

            #endregion
        }

19 Source : SoftBasicExample.cs
with GNU Lesser General Public License v3.0
from HslCommunication-Community

public void IsTwoTokenEquelExample( )
        {
            #region IsTwoTokenEquelExample

            Guid guid = new Guid( "56b79cac-91e8-460f-95ce-72b39e19185e" );
            byte[] b2 = new byte[32];
            guid.ToByteArray( ).CopyTo( b2, 12 );

            Console.WriteLine( SoftBasic.IsByteTokenEquel( b2, guid ) );

            // 输出 true

            #endregion
        }

See More Examples