Tuesday, 30 April 2024

Monday, 29 April 2024

Equality Operator (==) and Equals() Method

 

 Difference between the Equality Operator (==) and Equals() Method in C#?

Although both are used to compare two objects by value, still they both are used differently. 

For ex.:

int x = 10;
int y = 10;
Console.WriteLine( x == y);
Console.WriteLine(x.Equals(y));
Output:
True
True

Equality operator (==) is a reference type which means that if equality operator is used, it will return true only if both the references point to the same object.  

Equals() method: Equals method is used to compare the values carried by the objects. int x=10, int y=10. If x==y is compared then, the values carried by x and y are compared which is equal and therefore they return true. 

Equality operator: Compares by reference

Equals(): Compares by value

Generics

 

What are Generics in C#?

In C# collections, defining any kind of object is termed okay which compromises C#’s basic rule of type-safety. Therefore, generics were included to type-safe the code by allowing re-use of the data processing algorithms. Generics in C# mean not linked to any specific data type. Generics reduce the load of using boxing, unboxing, and typecasting objects. Generics are always defined inside angular brackets <>. To create a generic class, this syntax is used:

GenericList<float> list1 = new GenericList<float>();
GenericList<Features> list2 = new GenericList<Features>();
GenericList<Struct> list3 = new GenericList<Struct>();

Here, GenericList<float> is a generic class. In each of these instances of GenericList<T>, every occurrence of T in the class is substituted at run time with the type argument. By substituting the T, we have created three different type-safe using the same class

Abstract class

  Abstract classes are classes that cannot be instantiated where you cannot create objects. Abstract classes work on the OOPS concept of abstraction. Abstraction helps to extract essential details and hide the unessential ones.

Sealed class: Sealed classes are classes that cannot be inherited. Use the keyword sealed to restrict access to users to inherit that class.

What is a managed and unmanaged code?

Managed code lets you run the code on a managed CLR runtime environment in the .NET framework. 
Managed code runs on the managed runtime environment than the operating system itself. 
Benefits: Provides various services like a garbage collector, exception handling, etc. 

Unmanaged code is when the code doesn’t run on CLR, it is an unmanaged code that works outside the .NET framework. 
They don’t provide services of the high-level languages and therefore, run without them. Such an example is C++.

6. What is the difference between an abstract class and an interface?

Let’s dig into the differences between an abstract class and an interface:

  • Abstract classes are classes that cannot be instantiated ie. that cannot create an object. The interface is like an abstract class because all the methods inside the interface are abstract methods.
  • Surprisingly, abstract classes can have both abstract and non-abstract methods but all the methods of an interface are abstract methods.
  • Since abstract classes can have both abstract and non-abstract methods, we need to use the Abstract keyword to declare abstract methods. But in the interface, there is no such need.

An abstract class has constructors while an interface encompasses none. 

exception handling

 exception handling 

https://www.w3resource.com/csharp-exercises/exception-handling/index.php

https://ankitsharmablogs.com/csharp-coding-questions-for-technical-interviews/


Sunday, 28 April 2024

singleton vs static

 https://www.crackjob.co.in/2023/12/singleton-vs-static.html

https://medium.com/@ashishsharma.knox/mastering-c-20-interview-questions-and-answers-with-real-world-examples-for-success-part-1-a56018e6fcc7

https://www.linkedin.com/feed/hashtag/?keywords=csharpinterview


Generics

 https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation?source=recommendations



Static class benfits

 

 Key Points to Remember for a Technical Interview

  1. Static classes cannot be instantiated or extended.
  2. A static class can only contain static members.
  3. Static members are accessed via the class name, not an instance of the class.
  4. Static classes are sealed and therefore cannot be inherited.
  5. Static constructors are called automatically when a static member is referenced.
  6. Static members are initialized only once, at the class loading.
  7. The 'this' keyword is not available in static methods since they belong to the class, not an instance of the class.

What is the use of static class?

 What is the use of static class?

Static classes are used as containers for static members. Static methods and static properties are the most-used members of a static class. All static members are called directly using the class name. Static methods do a specific job and are called directly using a type name, rather than the instance of a type.
When to use static classes in C#?
Static classes and members are usually used for data or functions that do not change in response to object state, or for utility functions that do not rely on object state at all. One common use of static classes is to hold application-level data, such as configuration

static void Main(string[] args)
{
    string sourceString, reversestring;
    Reversestring(out sourceString, out reversestring);
    Console.WriteLine("sourece string is {0} \n reverse string is {1}", sourceString, reversestring);
    Console.ReadLine();

}
private static void Reversestring(out string sourceString, out string reversestring)
{
    reversestring = "";
    Console.WriteLine("Please Enter string you would like to revese");
    sourceString = Console.ReadLine();
    for (int i = sourceString.Length - 1; i >= 0; i--)
    {
        reversestring += sourceString[i];
    }
}

Angular interview question

 https://www.radzen.com/blog/angular-event-bubbling/

Event Bubbling

https://blog.stackademic.com/event-bubbling-capturing-trickling-and-event-delegation-in-details-8f1c9af0e37d


Singleton in c#

 

singleton

https://rajndev.medium.com/the-big-picture-common-patterns-in-software-development-32dfb52cf745


Lazy initialization

LAZY in C# 


Lazy initialization is a technique that defers the creation of an object until the first time it is needed. In other words, initialization of the object happens only on demand. Note that the terms lazy initialization and lazy instantiation mean the same thing—they can be used interchangeably. By taking advantage of lazy initialization, you can improve the application’s performance by avoiding unnecessary computation and memory consumption. In this article we’ll look at how we can perform lazy initialization in C#.

Let’s understand lazy loading with a simple example. Consider two classes, Customer and Order. The Customer class contains an Orders property that in turn references a collection of instances of the Order class. The Orders collection may contain a large amount of data and may even need a database connection to connect to the database and retrieve records. In such a case, there is no point in loading data in the Orders property until we need the data. Lazy initialization allows us to load the Orders collection only when the data is asked for.

angular issues

 1.before excuting api which return id the next line being excuting.

2.after refresh model dtabale also cleared.

Friday, 26 April 2024

reduce in typescipt

 calculate sum of the amount use below logic

this.TotalAmount=  res.reduce((total, current) => total +
(current.Quantity * current.UnitPrice), 0);



i have two arrays need to loop those and and description.
intad of getting data usign joins i have using below logic to add description ot items list



 if(this.lstGlcode.length >0){
            res.forEach(y=>{
              let gldesc=this.lstGlcode.find(x=>x.Id === y.GldescriptionId)
              if(gldesc){
                y.GlDescription=gldesc.Description;
              }
            })
        }

Thursday, 25 April 2024

viewchild real time example

 below is the image of child component it is given in parent clss.

1.my ask is after saving purchase order final save we get poid then only we save below data to api

so. i need to click save function after poid created .

so i used viewchild concept like below.

using this we can access component all methods inside parent component.


while giving in constructor getting error.inject error

 @ViewChild(POOrderItemsListComponent, { static: false })
  public poList!: POOrderItemsListComponent;
  constructor(private poservice: PurchaseorderService,
    private poList: POOrderItemsListComponent)


here i am accessing child class method like below.
 cancel() {
    // Logic for cancel button
    this.poList.finalSave();
  }


LINQ ADDRange

 Find diffrenece bettwen for ADD and ADDRange in c# push object to the list..

Pipes to sum price

  transform(quantity: number, unitprice: number): any {

    if (isNaN(quantity) || quantity === null) return ''; // Handle non-numeric values
    if (isNaN(unitprice) || unitprice === null) return '';
    // Round the number to the specified decimal places
    // const roundedValue = Number(value.toFixed(decimalPlaces));
      const exitprice=quantity * unitprice;
        return exitprice
  }



Here based on two fields data should update.
so writen pipe
in html given pipe like this
[value]='orderItemObj.Quantity | exitprice:orderItemObj.UnitPrice' for input
firstvalue ,pipe,second value.







Tuesday, 23 April 2024

aws

 https://aws.amazon.com/blogs/dotnet/build-dr-ready-net-web-apis-on-aws/


Sunday, 21 April 2024

dapper with out parameter

 


                    var parameters = new DynamicParameters();

                    parameters.Add("@workflowName", workflowName);

                    parameters.Add("@workflowExists", dbType: DbType.Boolean, direction: ParameterDirection.Output);


                    con.Execute(DBSPs.checkWorkflowexists, parameters, commandType: CommandType.StoredProcedure);


                    return parameters.Get<bool>("@workflowExists");

Saturday, 13 April 2024

Novels

 https://cloud.3dissue.com/18743/41457/106040/freesampler/index.html?r=48

Friday, 12 April 2024

Wednesday, 10 April 2024

course content

 https://www.educative.io/courses/learn-object-oriented-programming-in-c-sharp


job

 https://7peakssoftware-hr.freshteam.com/jobs/n025jowPucN1/tech-lead-net?ft_source=Seven+Peaks+Website_1000142298&ft_medium=Portal_1000132040&utm_source=linkedin&utm_medium=linkedin_feed&utm_content=post&utm_campaign=sps-recruit-recruit-generic-linkedin&gclid=CjwKCAjw6MKXBhA5EiwANWLODOcXEmI8LsID5iQFQ9BWtl_gJ-9JyvEleTQVatA7FZXv3J97SY780BoCtpcQAvD_BwE&_gl=1*a7uvao*_ga*MTA5ODg1NjgxOC4xNzEyNzY1NDI2*_ga_CYRZBWL6BM*MTcxMjgwMjUwMy4xLjEuMTcxMjgwMjUyNi4zNy4wLjA.


Monday, 8 April 2024

personal

 https://employee.benefitsyou.com/EMPLOYEEENROLLMENT.ASPX


Rxjs Operators.docx



Error handle c#

Error Handle global class like this. 

 public class Result<T>

{

    public bool IsSuccess { get; private set; }

    public T Data { get; private set; }

    public string ErrorMessage { get; private set; }


    private Result(bool isSuccess, T data, string errorMessage)

    {

        IsSuccess = isSuccess;

        Data = data;

        ErrorMessage = errorMessage;

    }


    public static Result<T> Success(T data)

    {

        return new Result<T>(true, data, null);

    }


    public static Result<T> Failure(string errorMessage)

    {

        return new Result<T>(false, default(T), errorMessage);

    }

}

sample code

public async Task<Result<List<Users>>> GetUserSearch(string searchValue, string NetworkID)
{
    using (var con = _dapperDbConnection.CreateConnection())
    {
        try
        {
            var parmas = new
            {
                searchValue,
                NetworkID,
            };
            var result = await con.QueryAsync<Users>(DBSPs.getusersearch, parmas, commandType: CommandType.StoredProcedure);
            return Result<List<Users>>.Success(result.ToList());
        }
        catch (Exception ex)
        {
            return Result<List<Users>>.Failure($"Error occurred: {ex.Message}");
        }
        finally
        {
            con.Close();
        }
    }
}

design patterns

https://www.linkedin.com/pulse/mastering-memento-design-pattern-cnet-roman-fairushyn-ojedf/?trackingId=xBHEDEu1EjLf2Dvcb11dJw%3D%3D

https://medium.com/@yohata/mastering-ddd-repository-design-patterns-in-go-2034486c82b3


esign Patterns (C#)

  • Head First Design Patterns (Eric Freeman, Elisabeth Freeman, Bert Bates, Kathy Sierra)

  • Design Patterns in C# and .NET (Dirk Draheim)

  • Applied Architecture Patterns on the Microsoft Platform (Dino Esposito)

  • Design Patterns in C# (Steve Metsker)

  • C# Design Patterns: A Tutorial (Judith Bishop)


https://github.com/snikolictech/Essential_Design_Patterns_in_C-Sharp_by_Steven_Nikolic

Wednesday, 3 April 2024

error while saving large data

 while sending data to the backend got the error.


beacuse model class field sequence is different and send payload sequence diferetnt 

table and model class sqnc should be same

{
  "Id": 0,
  "Status": false,
  "Message": "Error converting data type nvarchar to numeric.\r\nThe data for table-valued parameter \"@dtWorkflowMems\" doesn't conform to the table type of the parameter. SQL Server error is: 8114, state: 5\r\nThe statement has been terminated."
}

Ado.net and dapper for Multiple list

 Here how to retrieve mutiple list using dapper as well as dapper

Using Dapper

        async Task<vmWorkFlowManagement> IWorkFlowAdminRepository.GetWorkflowDetails(int WorkflowID)

        {

            using (var con = _dapperDbConnection.CreateConnection())

            {

                var result=new vmWorkFlowManagement();

                DynamicParameters param = new DynamicParameters();

                param.Add("Workflow_ID", WorkflowID);

                var reader = await con.QueryMultipleAsync(DBSPs.getworkflowdetails, param, commandType: CommandType.StoredProcedure);

                result.WorkFlows= reader.Read<WorkFlows>().FirstOrDefault();

                result.ListWorkFlowMembers=reader.Read<WorkFlowMembers>().ToList();

            }

        }



 

using ADO.net

public vmWorkFlowManagement GetWorkflowDetails(string WorkflowID)

{

var result = new vmWorkFlowManagement();

DataSet ds = SqlHelper.ExecuteDataset(Harsco_AFIWeb_ConnectionString, "[dbo].[USP_GetWorkflowDetails]", WorkflowID);

if (ds.Tables.Count > 0)

{

result.WorkFlows = (ds.Tables[0].Rows.Count > 0) ? DataTableHelper.ConvertDataTable<WorkFlows>(ds.Tables[0]).FirstOrDefault() : new WorkFlows();

result.ListWorkFlowMembers = (ds.Tables[0].Rows.Count > 0) ? DataTableHelper.ConvertDataTable<WorkFlowMembers>(ds.Tables[1]) : new List<WorkFlowMembers>();

}

return result;

}






Tuesday, 2 April 2024

jobs for blazor

 blazor jd

Software Developer (MUST HAVE BLAZOR EXP) 7+

Senior Software Engineer : Hands-on experience in Blazor (Service apps or Web Assembly) is mandatory

Working Hours : 9:00am to 6:00pm.

Location : Remote (Need to visit Pune/Bangalore/Chennai/Trivandrum Office once in a month).

Responsibilities :

- Participate in the entire software development lifecycle (SDLC), which includes analysis, design, testing, and deployment

- Develop software applications using various programming languages and technologies

- Collaborate with team members to define solutions and implement them

- Write clean, well-designed, and testable code

- Troubleshoot, debug, and upgrade existing software

- Document and maintain software functionality

- Integrate software components into a fully functional system

- Develop software verification plans and quality assurance procedures

- Deploy programs and evaluate user feedback to recommend and implement improvements

- Stay up-to-date with the latest technologies and industry standards

Skills :

- Proficiency in one or more programming languages (e.g., Java, Python, C++)

- Understanding of software development methodologies (e.g., Agile, Waterfall)

- Problem-solving and analytical skills

- Excellent communication and collaboration skills

- Ability to work independently and as part of a team

Everyday job site links

 https://www.hirist.tech/

Azure links

 https://microsoft.github.io/AzureTipsAndTricks/

Car pooling app

 I'll create a car pooling app with real-time vehicle tracking, pickup/drop time estimates, and a list of onboard users. Since we don...