Chandu yadav

Chandu yadav

810 Articles Published

Articles by Chandu yadav

Page 8 of 81

How to convert JS date time to MySQL datetime?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 1K+ Views

We can convert JS date time to MySQL datetime with the help of toISOString() function.Let us see an example of JavaScript.Example           Web Page Design                document.writeln(new Date().toISOString().slice(0, 19).replace('T', ' '));              Current Date is displayed above... OutputThe following is the output.2018-11-23 11:14:38 Current Date is displayed above...

Read More

C# Queryable SequenceEqual() Method

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 151 Views

To check whether two sequences are equal or not, use the SequenceEqual() method.Firstly, set the sequences.Employee emp1 = new Employee { EmployeeRank = 4, EmpName = "Amit", EmpMarks = 90 }; Employee emp2 = new Employee { EmployeeRank = 5, EmpName = "Raman", EmpMarks = 95 }; List employee1 = new List { emp1, emp2 }; List employee2 = new List { emp1, emp2 };Now, find whether the sequences are equal or not.employee1.AsQueryable().SequenceEqual(employee2);Here is the example that shows the result.Exmapleusing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       Employee emp1 ...

Read More

C# Numeric (“N”) Format Specifier

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 2K+ Views

The numeric ("N") format specifier converts a number to a string of the following form −"-d,ddd,ddd.ddd…"Above,"-" is a negative number symbol if required,"d" is a digit (0-9), "," indicates a group separator,"." is a decimal point symbolExampleusing System; using System.Globalization; class Demo {    static void Main() {       double val1 = -5566.789;       Console.WriteLine(val1.ToString("N", CultureInfo.InvariantCulture));       int val2 = 87987766;       Console.WriteLine(val2.ToString("N3", CultureInfo.InvariantCulture));    } }Output-5,566.79 87,987,766.000

Read More

Replace All Elements Of ArrayList with with Java Collections

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 2K+ Views

In order to replace all elements of ArrayList with Java Collections, we use the Collections.fill() method. The static void fill(List list, Object element) method replaces all elements in the list with the specified element in the argument.Declaration −The java.util.Collections.fill() method is declared as follows −public static void fill(List

Read More

How do we access elements from the two-dimensional array in C#?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 4K+ Views

A 2-dimensional array can be thought of as a table, which has x number of rows and y number of columns.An element in 2-dimensional array is accessed by using the subscripts. That is, row index and column index of the array.int x = a[1, 1]; Console.WriteLine(x);Let us see an example that shows how to access elements from two-dimensional array.Exampleusing System; namespace Demo {    class MyArray {       static void Main(string[] args) {          /* an array with 5 rows and 2 columns*/          int[, ] a = new int[5, 2] {{0, ...

Read More

Swap elements of ArrayList with Java collections

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 10K+ Views

In order to swap elements of ArrayList with Java collections, we need to use the Collections.swap() method. It swaps the elements at the specified positions in the list.Declaration −The java.util.Collections.swap() method is declared as follows −public static void swap(List list, int i, int j)where i is the index of the first element to be swapped, j is the index of the other element to be swapped and list is the list where the swapping takes place.Let us see a program to swap elements of ArrayList with Java collections −Exampleimport java.util.*; public class Example {    public static void main ...

Read More

C# Linq LastorDefault Method

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 2K+ Views

Use the LastorDefault() method to return the last element of a sequence or a default value if element isn’t there.The following is our empty list.List val = new List { };Now the following will not be able to display the last element since the list is empty. Therefore, the default would get display and error won’t be shown.val.AsQueryable().LastOrDefault();The following is the code.Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List val = new List { };       double d = val.AsQueryable().LastOrDefault();       Console.WriteLine("Default Value = "+d);   ...

Read More

How to prevent Reflection to break a Singleton Class Pattern?

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 970 Views

A Singleton pattern states that a class can have a single instance and multiple instances are not permitted to be created. For this purpose, we make the constructor of the class a private and return a instance via a static method. But using reflection, we can still create multiple instance of a class by modifying the constructor scope. See the example below −Example - Breaking Singletonimport java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class Tester {    public static void main(String[] args) throws    InstantiationException, IllegalAccessException,    IllegalArgumentException, InvocationTargetException{       A a = A.getInstance();       ...

Read More

C# Program to convert a Byte value to an Int32 value

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 8K+ Views

To convert a Byte value to an Int32 value, use the Convert.ToInt32() method.Int32 represents a 32-bit signed integer.Let’s say the following is our Byte value.byte val = Byte.MaxValue;;Now to convert it to Int32.int intVal = Convert.ToInt32(val);Let us see the complete example.Exampleusing System; public class Demo {    public static void Main() {       byte val = Byte.MaxValue;;       int intVal = Convert.ToInt32(val);       Console.WriteLine("Converted byte {0} to Int32 {1} value ", val, intVal);    } }OutputConverted byte 255 to Int32 255 value

Read More

Display the package name of a class in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 6K+ Views

The package for a class can be obtained using the java.lang.Class.getPackage() method with the help of the class loader of the class. If there is no package object created by the class loader of the class, then null is returned.A program that demonstrates this is given as follows −Exampleimport java.util.Date; public class Main {    public static void main(String[] args) {       Date d = new Date();       Package p = d.getClass().getPackage();       String pName = p.getName();       System.out.println("The package name is: " + pName);    } }OutputThe package name is: java.utilNow ...

Read More
Showing 71–80 of 810 articles
« Prev 1 6 7 8 9 10 81 Next »
Advertisements