{"id":920,"date":"2019-12-03T07:08:23","date_gmt":"2019-12-03T07:08:23","guid":{"rendered":"https:\/\/blog.amt.in\/?p=920"},"modified":"2019-12-03T07:08:23","modified_gmt":"2019-12-03T07:08:23","slug":"introduction-to-c-2","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2019\/12\/03\/introduction-to-c-2\/","title":{"rendered":"Introduction to C#"},"content":{"rendered":"<p>C#\u00c2\u00a0is a general-purpose,\u00c2\u00a0multi-paradigm programming language\u00c2\u00a0encompassing\u00c2\u00a0strong typing,\u00c2\u00a0lexically scoped,\u00c2\u00a0imperative,\u00c2\u00a0declarative,\u00c2\u00a0functional,\u00c2\u00a0generic,\u00c2\u00a0object-oriented\u00c2\u00a0(class-based), and\u00c2\u00a0component-oriented\u00c2\u00a0programming disciplines.\u00c2\u00a0It was developed around 2000 by\u00c2\u00a0Microsoft\u00c2\u00a0as part of its\u00c2\u00a0.NET\u00c2\u00a0initiative, and later approved as an\u00c2\u00a0international standard\u00c2\u00a0by\u00c2\u00a0Ecma\u00c2\u00a0(ECMA-334) and\u00c2\u00a0ISO\u00c2\u00a0(ISO\/IEC 23270:2018).\u00c2\u00a0Mono\u00c2\u00a0is the name of the free and open-source project to develop a compiler and runtime for the language. C# is one of the programming languages designed for the\u00c2\u00a0Common Language Infrastructure\u00c2\u00a0(CLI).<\/p>\n<p>C# was designed by\u00c2\u00a0Anders Hejlsberg, and its development team is currently led by\u00c2\u00a0Mads Torgersen. The most recent version is 8.0, which was released in 2019 alongside\u00c2\u00a0Visual Studio 2019\u00c2\u00a0version 16.3.<\/p>\n<p>The Ecma standard lists these design goals for C#:<\/p>\n<ul>\n<li>The language is intended to be a simple, modern, general-purpose,\u00c2\u00a0object-oriented programming\u00c2\u00a0language.<\/li>\n<li>The language, and implementations thereof, should provide support for software engineering principles such as\u00c2\u00a0strong type\u00c2\u00a0checking, array\u00c2\u00a0bounds checking, detection of attempts to use\u00c2\u00a0uninitialized variables, and automatic\u00c2\u00a0garbage collection. Software robustness, durability, and programmer productivity are important.<\/li>\n<li>The language is intended for use in developing\u00c2\u00a0software components\u00c2\u00a0suitable for deployment in distributed environments.<\/li>\n<li>Portability is very important for source code and programmers, especially those already familiar with\u00c2\u00a0C\u00c2\u00a0and\u00c2\u00a0C++.<\/li>\n<li>Support for\u00c2\u00a0internationalization\u00c2\u00a0is very important.<\/li>\n<li>C# is intended to be suitable for writing applications for both hosted and\u00c2\u00a0embedded systems, ranging from the very large that use sophisticated\u00c2\u00a0operating systems, down to the very small having dedicated functions.<\/li>\n<li>Although C# applications are intended to be economical with regard to memory and\u00c2\u00a0processing power\u00c2\u00a0requirements, the language was not intended to compete directly on performance and size with C or assembly language<\/li>\n<\/ul>\n<p>Some notable features of C# that distinguish it from C, C++, and Java where noted, are:<\/p>\n<p><span id=\"Portability\" class=\"mw-headline\">Portability:<\/span><\/p>\n<p>By design, C# is the programming language that most directly reflects the underlying\u00c2\u00a0Common Language Infrastructure\u00c2\u00a0(CLI).\u00c2\u00a0Most of its intrinsic types correspond to value-types implemented by the CLI framework. However, the language specification does not state the code generation requirements of the compiler: that is, it does not state that a C# compiler must target a Common Language Runtime, or generate\u00c2\u00a0Common Intermediate Language\u00c2\u00a0(CIL), or generate any other specific format. Theoretically, a C# compiler could generate machine code like traditional compilers of C++ or\u00c2\u00a0Fortran.<\/p>\n<p><span id=\"Typing\" class=\"mw-headline\">Typing:<\/span><\/p>\n<p>C# supports strongly typed implicit variable declarations with the keyword\u00c2\u00a0<code>var<\/code>, and implicitly typed arrays with the keyword\u00c2\u00a0<code>new[]<\/code>\u00c2\u00a0followed by a collection initializer.<\/p>\n<p>C# supports a strict\u00c2\u00a0Boolean data type,\u00c2\u00a0<code>bool<\/code>. Statements that take conditions, such as\u00c2\u00a0<code>while<\/code>\u00c2\u00a0and\u00c2\u00a0<code>if<\/code>, require an expression of a type that implements the\u00c2\u00a0<code>true<\/code>\u00c2\u00a0operator, such as the Boolean type. While C++ also has a Boolean type, it can be freely converted to and from integers, and expressions such as\u00c2\u00a0<code>if(a)<\/code>\u00c2\u00a0require only that\u00c2\u00a0<code>a<\/code>\u00c2\u00a0is convertible to bool, allowing\u00c2\u00a0<code>a<\/code>\u00c2\u00a0to be an int, or a pointer. C# disallows this &#8220;integer meaning true or false&#8221; approach, on the grounds that forcing programmers to use expressions that return exactly\u00c2\u00a0<code>bool<\/code>\u00c2\u00a0can prevent certain types of programming mistakes such as\u00c2\u00a0<code>if (a = b)<\/code>\u00c2\u00a0(use of assignment\u00c2\u00a0<code>=<\/code>\u00c2\u00a0instead of equality\u00c2\u00a0<code>==<\/code>).<\/p>\n<p><span id=\"Language_Integrated_Query_(LINQ)\" class=\"mw-headline\">Language Integrated Query (LINQ):<\/span><\/p>\n<p>C# has the ability to utilize\u00c2\u00a0LINQ\u00c2\u00a0through the .NET Framework. A developer can query any\u00c2\u00a0<code>IEnumerable&lt;T&gt;<\/code>\u00c2\u00a0object, XML documents, an ADO.NET dataset, and a SQL database.\u00c2\u00a0Using LINQ in C# brings advantages like\u00c2\u00a0Intellisense\u00c2\u00a0support, strong filtering capabilities, type safety with compile error checking ability, and consistency for querying data over a variety of sources.\u00c2\u00a0There are several different language structures that can be utilized with C# with LINQ and they are query expressions, lambda expressions, anonymous types, implicitly typed variables, extension methods, and object initializers.<\/p>\n<p><span id=\"Functional_programming\" class=\"mw-headline\">Functional programming:<\/span><\/p>\n<p>Though primarily an imperative language, C# 2.0 offered limited support for functional programming through\u00c2\u00a0first-class functions\u00c2\u00a0and closures in the form of anonymous delegates. C# 3.0 expanded support for functional programming with the introduction of a lightweight syntax for lambda expressions, extension methods (an affordance for modules), and a\u00c2\u00a0list comprehension\u00c2\u00a0syntax in the form of a &#8220;query comprehension&#8221; language. C# 7.0 adds features typically found in functional languages like tuples and pattern matching.<\/p>\n<p>The above is a brief about C#. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#\u00c2\u00a0is a general-purpose,\u00c2\u00a0multi-paradigm programming language\u00c2\u00a0encompassing\u00c2\u00a0strong<\/p>\n","protected":false},"author":1,"featured_media":922,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[215,154,7],"tags":[216,156,18],"class_list":["post-920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c","category-programming-language","category-techtrends","tag-c","tag-programming-language","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=920"}],"version-history":[{"count":1,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/920\/revisions"}],"predecessor-version":[{"id":921,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/920\/revisions\/921"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/922"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}