Posts

Showing posts with the label c#

Resolved Issue in Asp core 3.0 serializersettings does not exist in AddJsonOptions

Hello, When we want to use serializersettings  function in configure service (IN startup .cs) for CamelCasing .then we get this issue  in asp core 3.0. So we can resolve it by adding below code in configure service file public void ConfigureServices(IServiceCollection services) { services.AddMvc(setupAction => { setupAction.EnableEndpointRouting = false; }).AddJsonOptions(jsonOptions => { jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null; }) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

.Net most asked interview questions for experienced professionals (C#,Asp WEBFORM,MVC,ASP CORE,WEB API,SQL Server,Java Script,Jquery)

Hello All Recently I have participated in multiple interviews. I found a lot of most frequently asked questions on the .Net framework. So I am just going to share with you, I hope it will be helpful while interview. I am just starting from C# questions and you have to find the answer over the Internet. I will update more question later C# Question    What is manage/Unmanaged code in c#  Tell me one scenario, Use of Interface instead of Abstract? Difference between Abstract Class and Interface with Scenario when to use it (Brief explain ) What happens if the inherited interfaces have conflicting method names? If one interface has 5 methods and wants to implement only 2 methods derived class. How can we do it? What Difference between Abstract and virtual method  and why we use if both near to  same  What is Constructor and its type, Default, Public, Private, Static  What is the Constructor Chaining in C#? What is...

how to make a program which checks and count occurrences Value in An Array in c#

Image
In this article, I will show, how to make a program which checks and count occurrences value in an Array  in c# using System; using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; namespace testconsole {     class Program     {               static void Main(string[] args)         {             int[] myArray = new int[] { 1, 2, 3, 4, 5, 6, 2, 2 };             string chekvalue = "";             for  (int i = 0; i < myArray.Length-1; i++)             {             if (chekvalue.Contains(myArray[i].ToString()))                 {                 }                 else { ...

how to make a program which checks and count occurrences characters in a string in c#

Image
In this article, I will show, how to make a program which checks and count occurrences characters in a string in c# using System; using System.Collections; using System.Collections.Generic; using System.Linq.Expressions; namespace testconsole {     class Program     {               static void Main(string[] args)         {             string input = "this is Manvendrs Patel Blog ";             string chekvalue = "";             for  (int i = 0; i < input.Length; i++)             {             if (chekvalue.Contains(input[i].ToString()))                 {                 }                 else {      ...

How to Remove Duplicate characters from String in C#

Image
Hello All, In this Program, I will show you, how to make a program to remove duplicate characters from strings using c# using System; using System.Collections.Generic; namespace testconsole { class Program { static void Main(string[] args) { string Stringvalue = "this is Apple"; string result = ""; Console.WriteLine("Before remove duplicate character :{0} ", Stringvalue); foreach (char ch in Stringvalue) { if(result.Contains(ch.ToString())) { } else { result = result + ch; } } Console.WriteLine("after remove duplicate character :{0} ", result); Console.ReadKey(); } } }

How to Check any value in Array element is duplicate or not in C#

Image
In this article, I will show you how to make a simple program to check any value is duplicate or not in Array. It will return true if the value exists duplicate in Array else false. using System; using System.Collections.Generic; namespace testconsole { class Program { static void Main(string[] args) { Console.WriteLine(checkduplicate(1,2,3,2,2)); Console.ReadLine(); } public static bool checkduplicate(params int[] A) { Dictionary<int, int> d = new Dictionary<int, int>(); foreach (int i in A) { if (d.ContainsKey(i)) return true; else d.Add(i, 1); } return false; } } }

Dynamic Mega Menu With Asp.Net with c#,java script and Sql Server.

Image
Introduction: In this article you’ll see how to Create dynamic  Mega Menu in asp.net .Having a menu and sub menus with links is very normal in a Web application. Typically, we create static menu and menu items. But sometimes we need dynamic mega menu when we do not know what the menu names and links will be called. Mega menus are a growing trend in web design . For sites that involve a lot of pages and/or products, a mega menu may be able to improve navigation and usability. Dynamic Mega Menu with ASP.NET, C#, jQuery and SQL Server solution that I would like to share with others puzzled with the same as was one of my website development i was having a tough time creating a Mega menu from database. Step1  Database:  I have 4 table category,subcategory  subcategory2 and  Brand  GO /****** Object:  Table [dbo].[tbl_Category]    Script Date: 07/30/2015 08:03:43 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON ...

Creating a Simple Hit Counter with ASP.NET 4.0 and C#

This tutorial will demonstrate how to create a simple system to count hits on  pages using a database with ASP.NET 4.0 and C#. STEPS : Just follow the steps and get result easily.  STEP-1 : CREATE NEW PROJECT Go to File > New > Project > Select asp.net web Form Application> Entry Application Name > Click OK. STEP-2: ADD A DATABASE. Go to Solution Explorer > Right Click on App_Data folder > Add >New Item> Select SQL Server Database Under Data > Enter Database name > Add. GO /****** Object:  Table [dbo].[tbl_Hits]    Script Date: 06/03/2014 16:04:51 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tbl_Hits](  [Hit_Id] [int] NULL,  [Hit_Name] [nvarchar](50) NULL,  [Hits] [nvarchar](50) NULL ) ON [PRIMARY] GO STEP-4:ADDING THE COONCETING STRING <connectionStrings>    <add name="ErpConnection" connectionString="Data Source=MANVENDRA;Initial C...

Dynamic SEO for c# website,How To Set Html Title, Meta Keywords & Meta Description From Asp.Net(C#.Net)

Dynamic SEO for c# website,How To Set Html Title, Meta Keywords & Meta Description From Asp.Net(C#.Net) Dynamic SEO for C# website. Task: Put SEO stuff (Title of page, Meta keyword, Meta description) in website using c# code in asp.net website/ web application. Onsite SEO –in Dynamic Website or E-Commerce Website. Description: Now these day SEO is a very important thing in a Website (Dynamic Website or E-Commerce Website). When we work on SEO for website then we require the setup page title, Meta keyword, Meta description. So we require option for this in admin panel for Content Management System Website. Here I use a small function for this, you can connect it to database and call on pageload. C# Code for Dynamic SEO   public   void  settitle( string  pagetitle,  string  metakeyword,  string  metadescription)     {          HtmlTitle  obj =  new   HtmlTitle ...

How to encrypt Bitmap image in c#

In this post I will show you how to encrypt bitmap image in c#.The technique is very simple.First we extract header from the image and then encrypt the rest byte data and then combined the header with this encrypted data. using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace Enc { class Program { static string FILENAME = @"D:\ub.bmp" ; static string ENCFILENAME = @"D:\enc.bmp" ; static void Main( string [] args) { //Create instance of DES TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider(); //Generate IV and Key des.GenerateIV(); des.GenerateKey(); //Set Encryption mode des.Mode = CipherMode.ECB; //Read FileStream fileStream = new FileStream(FILENAME,...

How to encrypt Bitmap image in c#

EXPLAIN  :Sometime we need to countdown timer on website as for bidding website or any else. Then we can use Ajax control to achieve this task. Here I created code for countdown timer (server time). I used server countdown timer because for bidding we need server time not client machine time which used in javascript code. note : need ajax control toolkit to add first. It is freely available at http://www.asp.net/ajaxlibrary/AjaxControlToolkitSamlpleSite/ Here, you can find many sample code for how use ajax controls in your website. In addition I make CSS for round corner of DIV tag. my div is as a circle. ........................................Design Page ... Save it as timer.aspx............................................................ <% @   Page   Language ="C#"   AutoEventWireup ="true"   CodeFile ="timer.aspx.cs" Inherits ="timer"   %> <% @   Register   assembly ="AjaxControlToolkit"   namespace ="...