SNCA:C#

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search


The average C# user.

C# is a general purpose programming language made by Microsoft, and is very similar to Java. It is also a C-derived language and has some similarities to C++ as well. It runs on the .NET runtime. Some game engines like Unity and Godot use C# for scripting. Five Nights at Cobson's was written in C#. You can use C# for basically everything you can use Java for. Because C# was created by Microsoft, it is mostly oriented towards Windows though it is also cross platform and can be run on Linux as well.

Soyteens are in debate over whether C# or Java is better. Some people prefer C# because it also has a massive standard library like Java, while providing many modern language features such as nullable types and better null safety, null coalescing, LINQ, and better native interfacing.

Unlike Java which compiles to .class files, C# compiles to .dll (dynamic linked library) files. Although C++ also can compile to .dll files, C++ DLLs and C# DLLs are not compatible.

Example[edit | edit source]

namespace SoyjakParty.Example;

using System;

public class Tranny
{
    private static readonly Random rand = new Random();

    /// <summary>
    /// Determines whether the tranny should ack based on a given probability.
    /// </summary>
    /// <param name="ackProbability">An integer between 0 and 100 representing the chance of acking.</param>
    /// <returns>True if the random probability is less than the ackProbability; otherwise, False.</returns>
    private static bool ShouldCrash(uint ackProbability)
    {
        double prob = rand.NextDouble() * 100;
        return prob < Math.Clamp(ackProbability, 0, 100);
    }

    /// <summary>
    /// Main function that decides whether to ack or print "TRANS RIGHTS ARE HUMAN RIGHTS!!!!".
    /// </summary>
    /// <param name="args">An array of command line arguments.</param>
    public static void Main(string[] args)
    {
        if (ShouldCrash(41))
        {
            throw new SystemException("ACK!!!!");
        }
        else
        {
            Console.WriteLine("TRANS RIGHTS ARE HUMAN RIGHTS!!!!!!!!");
        }
    }
}


C Sharp
is part of a series on
Soyience™

Visit the Soyence portal for more.
"We are all just hecking star dust or something!"
Peer reviewed sources [-+]
Fields of science [-+]
Science in praxis [-+]
Theoretical branches [-+]