C#

1 program Added 2025-10-22T16:38:39Z Model: google/gemini-2.5-proTemp: 0.4 Evidence Report issue View issues
Aliases: csharp
Provenance: commit 3c0274cf11 · authored 2025-10-22T18:38:39+02:00 · model google/gemini-2.5-pro

Sources mentioning this language

8 sources · pl_id: pl/csharp
LLM (this repo) · 1LinguistPygmentsWikipediaEsolangHyperpolyglotRosettacodeWikidata · Q2370

Wikipedia infobox

Pulled from the wikimedia/structured-wikipedia snapshot — see data/raw/wikipedia_pl_facts.*.jsonl and pl_fact.csv for the long-table provenance.

Paradigmsmulti-paradigm: structured · imperative · object-oriented · event-driven · task-driven · functional · generic · reflective · concurrent
Typingstatic, dynamic, strong, safe, nominative, partly inferred
Designed byMads Torgersen (Microsoft) · Anders Hejlsberg (Microsoft)
First appeared2000
Influenced byC++ · · Eiffel · F# · Haskell · Scala · Icon · J# · J++ · Java · JavaScript · ML · Modula-3 · Object Pascal · Visual Basic (VB)
LicenseRoslyn compiler: MIT/X11
Homepagehttps://learn.microsoft.com/en-us/dotnet/csharp/

Extensions claimed by this language

7 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.cslinguistprimary345.7M files
.cspygmentsprimary345.7M files
.cswikidataprimary345.7M files
.csxwikidataprimary61.1K files
.cakelinguistsecondary74.0K files
.csxlinguistsecondary61.1K files
.linqlinguistsecondary50.0K files

Related languages

Spec# (0.32)Carp (0.31)A# (0.28)F# (0.24)LSharp (0.24)

LLM-contributed programs

ResizeSize Model for PowerToys ImageResizer

Provenance: commit 3c0274cf11 · authored 2025-10-22T18:38:39+02:00 · model google/gemini-2.5-pro · Temp 0.4
code.cs · license: MIT · added: 2025-10-22T16:38:39Z
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Globalization;
using System.Text.Json.Serialization;
using System.Windows;
using ImageResizer.Properties;
using ImageResizer.Utilities;

namespace ImageResizer.Models
{
    public class ResizeSize
    {
        [JsonPropertyName("name")]
        public string Name { get; set; }

        [JsonPropertyName("width")]
        public double Width { get; set; }

        [JsonPropertyName("height")]
        public double Height { get; set; }

        [JsonPropertyName("unit")]
        public ResizeUnit Unit { get; set; }

        [JsonPropertyName("fit")]
        public ResizeFit Fit { get; set; }

        [JsonIgnore]
        public string Description
        {
            get
            {
                string unit = Unit switch
                {
                    ResizeUnit.Centimeter => Resources.Centimeter,
                    ResizeUnit.Inch => Resources.Inch,
                    ResizeUnit.Percent => Resources.Percent,
                    _ => Resources.Pixel,
                };

                string fit = Fit switch
                {
                    ResizeFit.Fill => Resources.Fill,
                    ResizeFit.Fit => Resources.Fit,
                    _ => Resources.Stretch,
                };

                return string.Format(
                    CultureInfo.CurrentCulture,
                    "{0} ({1})",
                    string.Format(
                        CultureInfo.CurrentCulture,
                        "{0} x {1} {2}",
                        Width,
                        Height,
                        unit),
                    fit);
            }
        }

        public Size GetPixelSize(int originalWidth, int originalHeight)
        {
            double width = 0;
            double height = 0;

            if (Unit == ResizeUnit.Percent)
            {
                width = originalWidth * Width / 100;
                height = originalHeight * Height / 100;
            }
            else
            {
                width = UnitConverter.ConvertToPixels(Width, Unit);
                height = UnitConverter.ConvertToPixels(Height, Unit);
            }

            if (Fit == ResizeFit.Fit)
            {
                double ratio = Math.Min(width / originalWidth, height / originalHeight);
                width = originalWidth * ratio;
                height = originalHeight * ratio;
            }
            else if (Fit == ResizeFit.Fill)
            {
                double ratio = Math.Max(width / originalWidth, height / originalHeight);
                width = originalWidth * ratio;
                height = originalHeight * ratio;
            }

            return new Size(Math.Max(1, width), Math.Max(1, height));
        }
    }
}

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Disambiguation rules

Linguist heuristic rules that predict this language when one of its claimed extensions is shared with another.
RuleExtKindPredicates (truncated)
h/linguist/.cs/1.cspredicates[{"kind": "any", "regexes": ["^\\s*(using\\s+[A-Z][\\s\\w.]+;|namespace\\s*[\\w\\.]+\\s*(\\{|;)|\\/\\/)"]}]

Contribute — propose a file extension

Tell us where to find evidence about C# (mapped to pl/csharp). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/C#/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← C Shell C* →