<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Vivek Nariya</title>
    <description>The latest articles on Forem by Vivek Nariya (@viveknariya).</description>
    <link>https://forem.com/viveknariya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1321907%2F04847672-1bf3-47c2-ba88-477cdbf02df2.jpg</url>
      <title>Forem: Vivek Nariya</title>
      <link>https://forem.com/viveknariya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/viveknariya"/>
    <language>en</language>
    <item>
      <title>All Sub-queries in SQL</title>
      <dc:creator>Vivek Nariya</dc:creator>
      <pubDate>Sat, 29 Jun 2024 13:20:17 +0000</pubDate>
      <link>https://forem.com/viveknariya/all-sub-queries-in-sql-3549</link>
      <guid>https://forem.com/viveknariya/all-sub-queries-in-sql-3549</guid>
      <description>&lt;p&gt;&lt;strong&gt;Subqueries, also known as inner queries or nested queries, are a powerful feature in SQL that allow you to perform more complex and flexible queries.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Schema
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE Department (
    Department_id INT PRIMARY KEY,
    Department_name VARCHAR(50) NOT NULL
);

CREATE TABLE Employee (
    Employee_id INT PRIMARY KEY,
    Employee_name VARCHAR(50) NOT NULL,
    Salary DECIMAL(10,2) NOT NULL,
    Department_id INT,
    FOREIGN KEY (Department_id) REFERENCES Department(Department_id)
);

INSERT INTO Department (Department_id, Department_name) VALUES
(1, 'HR'),
(2, 'IT'),
(3, 'Marketing'),
(4, 'Sales'),
(5, 'Finance');

INSERT INTO Employee (Employee_id, Employee_name, Salary, Department_id) VALUES
(1, 'Alice', 5000, 1),
(2, 'Bob', 7000, 1),
(3, 'Carol', 6000, 2),
(4, 'Dave', 6000, 2),
(5, 'Eve', 8000, 3),
(6, 'Frank', 9000, 3),
(7, 'Grace', 3000, 4),
(8, 'Hank', 4000, 4),
(9, 'Irene', 10000, 5),
(10, 'Jack', 9500, 5);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the SELECT Clause
Subqueries can be used in the SELECT clause to return a &lt;strong&gt;single value&lt;/strong&gt; that will be included in the result set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    Employee_id, 
    Employee_name, 
    (SELECT Department_name FROM Department WHERE Department_id = e.Department_id) AS DepartmentName
FROM 
    Employee e;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the FROM Clause
Subqueries can create a temporary table that can be joined with other tables in the FROM clause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    e.Employee_id, 
    e.Employee_name, 
    dept.Department_name
FROM 
    Employee e
INNER JOIN 
    (SELECT Department_id, Department_name FROM Department) dept
ON 
    e.Department_id = dept.Department_id;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the WHERE Clause
Subqueries can filter rows based on the result of another query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    Employee_id, 
    Employee_name, 
    Salary
FROM 
    Employee e
WHERE 
    Salary = (SELECT MAX(Salary) FROM Employee WHERE Department_id = e.Department_id);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the HAVING Clause
Subqueries can filter groups based on aggregate functions in the HAVING clause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    Department_id, 
    AVG(Salary) AS AvgSalary
FROM 
    Employee
GROUP BY 
    Department_id
HAVING 
    AVG(Salary) &amp;gt; (SELECT AVG(Salary) FROM Employee);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the JOIN Condition
Subqueries can be part of the join condition to dynamically determine the join criteria.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
    e.Employee_id, 
    e.Employee_name, 
    d.Department_name
FROM 
    Employee e
INNER JOIN 
    Department d ON e.Department_id = d.Department_id
AND 
    e.Salary &amp;gt; (SELECT AVG(Salary) FROM Employee WHERE Department_id = e.Department_id);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the INSERT Statement
Subqueries can provide the values to insert into a table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO 
    Employee (Employee_id, Employee_name, Salary, Department_id)
SELECT 
    new_employee_id, 
    new_employee_name, 
    new_salary, 
    new_department_id
FROM 
    (SELECT 
         11 AS new_employee_id, 
         'John Doe' AS new_employee_name, 
         5000 AS new_salary, 
         1 AS new_department_id
     ) new_employee;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the UPDATE Statement
Subqueries can determine the values to update in a table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE 
    Employee
SET 
    Salary = (SELECT AVG(Salary) FROM Employee WHERE Department_id = Employee.Department_id)
WHERE 
    Employee_id = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Subqueries in the DELETE Statement
Subqueries can determine which rows to delete from a table.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DELETE FROM 
    Employee
WHERE 
    Department_id IN (SELECT Department_id FROM Department WHERE Department_name = 'HR');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Subqueries are a versatile and essential tool in SQL, allowing for powerful and flexible data retrieval and manipulation. Understanding where and how to use subqueries can significantly enhance your ability to write complex SQL queries efficiently. By mastering the use of subqueries, you can tackle a wide range of data challenges in SQL.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>backend</category>
      <category>interview</category>
    </item>
    <item>
      <title>How to Serve an Angular App with Nginx</title>
      <dc:creator>Vivek Nariya</dc:creator>
      <pubDate>Mon, 15 Apr 2024 17:17:56 +0000</pubDate>
      <link>https://forem.com/viveknariya/how-to-serve-an-angular-app-with-nginx-46m3</link>
      <guid>https://forem.com/viveknariya/how-to-serve-an-angular-app-with-nginx-46m3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Installing Nginx on Windows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1... - Download the latest version of Nginx for Windows from the official Nginx website.&lt;/p&gt;

&lt;p&gt;2... - Extract the downloaded archive to a directory of your choice, such as C:\nginx.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;nginx.conf Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, let's configure Nginx to serve our Angular application. Below is a basic configuration file (nginx.conf) for serving an Angular app:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http {
    include mime.types;
    server {
        listen 2292;
        root /Users/vivek/Desktop/SAAS/saas_client/dist/sfms/browser;
    }
}
events{}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation of Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The provided Nginx configuration file consists of the following directives:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;http&lt;/strong&gt; This directive marks the beginning of the HTTP block, which defines global settings for Nginx.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;include mime.types;&lt;/strong&gt; This directive includes the mime.types file, which maps file extensions to their corresponding MIME types.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;server&lt;/strong&gt; This directive defines a server block within the HTTP block. A server block defines how Nginx handles requests for a specific domain name or port.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;listen 2292;&lt;/strong&gt; This directive specifies the port (2292) on which Nginx should listen for incoming connections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;root&lt;/strong&gt; /Users/vivek/Desktop/SAAS/saas_client/dist/sfms/browser; This directive sets the root directory from which Nginx should serve static files. [above location is location of build artifacts]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In this case, the Angular application's built output is located in the specified directory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Replacing Default nginx.conf&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To use the above configuration, follow these steps:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3... Locate the default nginx.conf file in the Nginx installation directory (typically C:\nginx\conf on Windows).&lt;/p&gt;

&lt;p&gt;4... Replace the contents of the default nginx.conf file with the configuration provided above.&lt;/p&gt;

&lt;p&gt;5... Save the changes to the nginx.conf file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Nginx Commands&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To start Nginx: Open Command Prompt and navigate to the Nginx directory (cd C:\nginx) and then run nginx.exe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To stop Nginx: Use the command nginx.exe -s stop.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To reload Nginx configuration: Use the command nginx.exe -s reload.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6... go to browser and hit localhost:2209&lt;/p&gt;

&lt;p&gt;7... its done!!!😀&lt;/p&gt;

</description>
      <category>angular</category>
      <category>nginx</category>
      <category>config</category>
      <category>webdev</category>
    </item>
    <item>
      <title>404, Nginx, Frontend, Angular</title>
      <dc:creator>Vivek Nariya</dc:creator>
      <pubDate>Mon, 11 Mar 2024 18:30:12 +0000</pubDate>
      <link>https://forem.com/viveknariya/404-nginx-frontend-angular-3p99</link>
      <guid>https://forem.com/viveknariya/404-nginx-frontend-angular-3p99</guid>
      <description>&lt;h2&gt;
  
  
  Solving 404 Errors with Hash-Based Routing in Angular Applications
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;This title emphasizes the issue of 404 errors encountered on the server side and how hash-based routing in Angular can effectively address this problem. It sets the stage for the reader to understand the significance of hash-based routing as a solution for managing client-side routing and preventing server-side errors.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;How Hash-Based Routing Works&lt;/strong&gt;&lt;br&gt;
Hash-based routing structures URLs in the following format :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://example.com/#/path/to/route
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The # symbol separates the base URL from the fragment identifier, which typically represents the application's route or state. When a user navigates to a URL with a hash-based route, the browser internally updates the document's location without sending a request to the server for the portion of the URL after the # symbol.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing Hash-Based Routing in Angular&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [
  // Define your application routes here
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes, { useHash: true }) // Configure to use hash-based routing
  ],
  exports: [RouterModule]
})
export class AppRoutingModule { }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Angular 17&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ApplicationConfig } from '@angular/core';
import { provideRouter, withHashLocation } from '@angular/router';

import { routes } from './app.routes';
import { provideHttpClient } from '@angular/common/http';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes,withHashLocation()),provideHttpClient()]
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Benefits of Hash-Based Routing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simplified Server Configuration : &lt;br&gt;
Hash-based routing eliminates the need for server-side route configuration or URL rewriting rules, as the server always serves the main HTML file regardless of the route specified in the fragment identifier.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistent Client-Side Behavior : &lt;br&gt;
Hash-based routing ensures consistent client-side routing behavior across different server environments, preventing 404 errors for routes handled by the client-side router.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Drawbacks of Hash-Based Routing&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Less Clean URLs : &lt;br&gt;
Hash-based URLs are less aesthetically pleasing and not as SEO-friendly as traditional URLs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limited Use Cases : &lt;br&gt;
Hash-based routing may not be suitable for applications requiring clean, semantic URLs or specific SEO requirements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>404</category>
      <category>nginx</category>
      <category>frontend</category>
    </item>
    <item>
      <title>In C#, readonly and const are both used to define constants, but they have some key differences</title>
      <dc:creator>Vivek Nariya</dc:creator>
      <pubDate>Mon, 04 Mar 2024 17:06:37 +0000</pubDate>
      <link>https://forem.com/viveknariya/in-c-readonly-and-const-are-both-used-to-define-constants-but-they-have-some-key-differences-4f3c</link>
      <guid>https://forem.com/viveknariya/in-c-readonly-and-const-are-both-used-to-define-constants-but-they-have-some-key-differences-4f3c</guid>
      <description>&lt;h2&gt;
  
  
  &lt;code&gt;const&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;1 . &lt;strong&gt;&lt;em&gt;Scope&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constants are &lt;strong&gt;implicitly static&lt;/strong&gt; and have a scope limited to the class or struct in which they are declared. They are essentially compile-time constants and can be accessed using the class or struct name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 . &lt;strong&gt;&lt;em&gt;Mutability&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constants declared with the &lt;code&gt;const&lt;/code&gt; keyword are implicitly static and cannot be changed after declaration. They are evaluated at compile time and remain constant throughout the program.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3 . &lt;strong&gt;&lt;em&gt;Value Assignment&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Values of &lt;code&gt;const&lt;/code&gt; fields must be known at compile time. They can only be assigned primitive types, enums, or strings.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;readonly&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;1 . &lt;strong&gt;&lt;em&gt;Scope&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;readonly&lt;/code&gt; fields are &lt;strong&gt;instance-level&lt;/strong&gt; constants. Each instance of the class or struct has its own copy of the readonly field, and they can have different values in different instances.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2 . &lt;strong&gt;&lt;em&gt;Mutability&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;readonly&lt;/code&gt; fields can be assigned a value either at the time of declaration or in a constructor. Once assigned, their value cannot be changed. They are evaluated at runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3 . &lt;strong&gt;&lt;em&gt;Value Assignment&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The value of a &lt;code&gt;readonly&lt;/code&gt; field can be determined at runtime. It can be assigned either at the time of declaration or within a constructor.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class ConstantsExample
{
    public const int ConstValue = 10; // Compile-time constant
    public readonly int ReadOnlyValue; // Runtime constant

    public ConstantsExample(int value)
    {
        ReadOnlyValue = value; // Assigning value in constructor
    }
}

class Program
{
    static void Main(string[] args)
    {
        // Accessing const field
        Console.WriteLine(ConstantsExample.ConstValue); // Output: 10

        // Creating instances with different readonly values
        ConstantsExample instance1 = new ConstantsExample(20);
        ConstantsExample instance2 = new ConstantsExample(30);

        Console.WriteLine(instance1.ReadOnlyValue); // Output: 20
        Console.WriteLine(instance2.ReadOnlyValue); // Output: 30
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>csharp</category>
      <category>beginners</category>
      <category>oop</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Classes - C# (Static, Abstract, Sealed)</title>
      <dc:creator>Vivek Nariya</dc:creator>
      <pubDate>Sun, 03 Mar 2024 15:14:35 +0000</pubDate>
      <link>https://forem.com/viveknariya/classes-c-static-abstract-sealed-4179</link>
      <guid>https://forem.com/viveknariya/classes-c-static-abstract-sealed-4179</guid>
      <description>&lt;p&gt;&lt;strong&gt;Static Class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor&lt;/em&gt;&lt;/strong&gt; : can not have&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor Invocation&lt;/em&gt;&lt;/strong&gt; : can not have&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Purpose&lt;/em&gt;&lt;/strong&gt; : Static classes are containers for utility methods and cannot be instantiated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Common Features&lt;/em&gt;&lt;/strong&gt; : Static members, static properties, static methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt; : No, in C#, a static class cannot contain non-static members, properties, or methods. Static classes are designed to provide a container for utility methods and constants and are typically used when you want to group methods and data that do not depend on instance data.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static class MathUtils
{
    public static int Add(int a, int b)
    {
        return a + b;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Abstract Class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor&lt;/em&gt;&lt;/strong&gt; : can have&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor Invocation&lt;/em&gt;&lt;/strong&gt; : Can be called through derived classes using &lt;code&gt;base&lt;/code&gt; keyword&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Purpose&lt;/em&gt;&lt;/strong&gt; : Abstract classes provide blueprints for other classes and cannot be instantiated on their own.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Common Features&lt;/em&gt;&lt;/strong&gt; : Abstract methods, virtual methods, protected members.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt; : Yes, an abstract class in C# can indeed have non-abstract methods, non-virtual methods, and non-protected members.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public abstract class Shape
{
    public abstract double CalculateArea();
    public abstract double CalculatePerimeter();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sealed Class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor&lt;/em&gt;&lt;/strong&gt; : can have&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Constructor Invocation&lt;/em&gt;&lt;/strong&gt; : Can be called normally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Purpose&lt;/em&gt;&lt;/strong&gt; : Sealed classes prevent inheritance and provide complete implementations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note&lt;/em&gt;&lt;/strong&gt; : When a class is declared as sealed using the &lt;code&gt;sealed&lt;/code&gt; keyword, it means that the class cannot be inherited. In other words, it prevents other classes from deriving from it. Sealed classes are typically used when you want to prevent further specialization or modification of a class.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sealed class MyClass
{
    // Class members
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>oop</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
