Is there a difference between C # and C # in .net? [closed]

-2

Good I am new in this, I have been studying java and I would like to study now C # that I have read that with the you can develop games and do desktop applications, but my doubt is, If I study c # in .net it is equal to the normal c # ? or is there a difference?

Thank you.

    
asked by jlgf 21.11.2017 в 15:46
source

1 answer

2

C # is the programming language. While .NET Framework is the set of libraries written in mostly C #.

For example System.IO is a library that belongs to the .NET Framework just like the class File , now, the class was written in C #.

The reason why it exists in the .NET Framework is to simplify tasks that would be very tedious and complicated mainly for beginners. For example, when you want to write a text in a file, you use:

System.IO.File.WriteAllText("ruta.txt", "Hola mundo");

Simple, right? This is all the framework does for you:

public static void WriteAllText(String path, String contents)
{
    if (path == null)
        throw new ArgumentNullException("path");
    if (path.Length == 0)
        throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"));
    Contract.EndContractBlock();

    InternalWriteAllText(path, contents, StreamWriter.UTF8NoBOM, true);
}

[System.Security.SecurityCritical]
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
private static void InternalWriteAllText(String path, String contents, Encoding encoding, bool checkHost)
{
    Contract.Requires(path != null);
    Contract.Requires(encoding != null);
    Contract.Requires(path.Length > 0);

    using (StreamWriter sw = new StreamWriter(path, false, encoding, StreamWriter.DefaultBufferSize, checkHost))
        sw.Write(contents);
} 

And in this example we do not include the implementation of StreamWriter that handles more complicated code. Here is the Write method from StreamWriter :

public override void Write(String value)
        {
            if (value != null)
            {

#if FEATURE_ASYNC_IO
                CheckAsyncTaskInProgress();
#endif

                int count = value.Length;
                int index = 0;
                while (count > 0) {
                    if (charPos == charLen) Flush(false, false);
                    int n = charLen - charPos;
                    if (n > count) n = count;
                    Contract.Assert(n > 0, "StreamWriter::Write(String) isn't making progress!  This is most likely a race condition in user code.");
                    value.CopyTo(index, charBuffer, charPos, n);
                    charPos += n;
                    index += n;
                    count -= n;
                }
                if (autoFlush) Flush(true, false);
            }
        }

And all that is summarized in the first example.

    
answered by 21.11.2017 / 17:04
source