Showing posts from May, 2022

C# Method to Check if a Number is Composite

In a previous post, we developed a C# method to check if an integer is a prime number or not. Today, we are going to develop a C# method to check if an integer is composite number or not. First, let's learn what is a composite number. What is a Composite Number? Any integer that is  prime is then considered as composite number because it can be divided by more than two numbers. Composite numbers are integers that have more than two factors. To summarize, an integer that can be divided by itself and by a number that is greater than 1, is …

How to Find All Distinct Elements of a Given Integer Array

In this post, we will learn how to find and print all distinct elements in an array. The given array may contain duplicates and it is not sorted, the C# solution should find and print every distinct element only once. Here are few examples: Input: arr[] = { 14 , 11 , 7 , 45 , 3 , 11 , 11 , 45 } Output: 14 , 11 , 7 , 45 , 3 Input: arr[] = { 1 , 2 , 3 , 4 , 5 } Output: 1 , 2 , 3 , 4 , 5 Input: arr[] = { 4 , 4 , 4 , 4 , 4 } Output: 4 Solution #1: Find all distinct elements of an integer array The first solution that may come to our mind is …

Phone Number Validation in JavaScript

In a previous post , we learnt how to validate a phone number input field in a HubSpot contact form. Today, we are going to explore two solutions to validate phone numbers using  JavaScript . Solution #1: Phone Number Validation using JavaScript and Regex The easiest way to validate phone numbers using JavaScript would be to use Regular expressions. First off, we should make sure that the format validator should not only support  NANP (country code +1) numbers. The regex that we will use should allow for a phone number from outside North Ameri…

C# Method to Check if a Number is Prime

If you participate in competitive programming assessment, you might be familiar with the fact that questions related to Prime numbers are one of the choices of the problem setter. In this post, we will write a C# method to check if a number is a prime but first let's explain what is a prime number.  What is a Prime Number A prime number is a whole number greater than 1 whose only factors are 1 and itself. A factor is a whole number that can be divided evenly into another number. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 2…

How to Compare Two Dates With JavaScript

JavaScript Date objects represent a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.  The Date object will do what you want - construct one for each date, then compare them using the >, <, <= or >=. The ==, !=, ===, and !== operators require you to use date.getTime() as in: var d1 = new Date (); var d2 = new Date (d1); var same = d1.getTime() === d2.getTime(); var notSame = d1.getTime() !== d2.getTime(); to be clear just checking fo…

General ASP.NET Performance Best Practices (Part-1)

In this article, we will explore seven performance best practices that are recommended to improve the performance of our ASP.NET web applications or web sites. As you progress and apply the performance-enhancing techniques to the ASP.NET applications, you will notice a decrease in its page load times, and a reduction in the overall page weight of each page in the ASP.NET web site or web application. Each technique is a building block that will make your pages lighter and load times quicker. IIS plays a big role in this part of the book, and yo…

Solving the Classic FizzBuzz Problem With .NET and C#

In this post, we’ll go through a classic interview question for developers: How to solve the FizzBuzz problem. You are asked to write a function that accepts an integer. The function must implement a loop from 1 to the integer that was passed into the function. In the loop the function must print the following to the command window: if the number is divisible by 3 then print “Fizz” if the number is divisible by 5 then print “Buzz” if the number is divisible by both 5 and 3 then print “FizzBuzz” otherwise just print the number itself We apply o…

Tutorial: How to Accelerate the Opening of SSIS Package in SSDT

When opening SSIS package, SSDT loads the package, validates it and shows you the validation results by default. To accelerate the opening of SSIS package, we enable you to skip package validation when opening the package and validate it when you want to, since SQL Server Integration Services Projects version 3.9 and SSDT for VS2017 15.9.6.  This tutorial walks you through the process on how to accelerate the opening of SSIS package by skipping package validation.   Switch “Skip validation when opening a package” on/off  To switch “Skip valida…

Execute SQL Statements in Azure Data Factory

In Azure Data Factory, a new activity has been introduced this year which is the Script activity. This is not the same as the script component of SSIS, which allows us to run .NET scripts. This task executes SQL script, so it is similar to the SSIS SQL Execute Task. This new activity in pipelines provides us the ability to execute single or multiple SQL statements. This is a nice feature, for the following reasons: We previously could only execute SQL scripts through the “Stored procedure” activity or we could use the Lookup component to execu…

Load More
That is All