Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by seetha
54 articles
How do I determine the size of my array in C#
Firstly, set an array −int[] arr = {6, 3, 8, 4};Now, use the Length property to get the size of the array −arr.LengthLet us see the complete code −Exampleusing System; namespace Demo { public class Demo { public static void Main(string[] args) { int[] arr = {6, 3, 8, 4}; Console.WriteLine("Array..."); foreach (int i in arr) { Console.Write(i + " "); } Console.WriteLine("Size of Array: "+arr.Length); } } }OutputArray... 6 3 8 4 Size of Array: 4
Read MorePrint first letter of each word in a string using C# regex
Let’s say our string is −string str = "The Shape of Water got an Oscar Award!";Use the following Regular Expression to display first letter of each word −@"\b[a-zA-Z]"Here is the complete code −Exampleusing System; using System.Text.RegularExpressions; namespace RegExApplication { public class Program { private static void showMatch(string text, string expr) { Console.WriteLine("The Expression: " + expr); MatchCollection mc = Regex.Matches(text, expr); foreach (Match m in mc) { Console.WriteLine(m); } } ...
Read MoreString Formatting in C# to add padding
With C#, you can easily format content and add padding to it.To add padding −const string format = "{0,-5} {1,5}";Now, add the padding to the strings −string str1 = string.Format(format, "Rank","Student"); string str2 = string.Format(format, "2","Tom");Let us see the complete code −Exampleusing System; using System.Collections.Generic; public class Program { public static void Main() { // set padding const string format = "{0,-5} {1,5}"; string str1 = string.Format(format, "Rank","Student"); string str2 = string.Format(format, "2","Tom"); Console.WriteLine(str1); Console.WriteLine(str2); } }OutputRank Student 2 Tom
Read MoreWhat is the class "class" in Java?
The Java.lang.Class class instance represent classes and interfaces in a running Java application. It has no public constructor. Example Following is the example demonstrates the usage of the class Class. The java.lang.Class.getCanonicalName() method returns the canonical name of the underlying class as defined by the Java Language Specification. It returns null if the class does not have a canonical name. import java.lang.*; public class ClassDemo { public static void main(String[] args) { ClassDemo c = new ClassDemo(); Class cls = c.getClass(); ...
Read MoreSet the width of the left border using CSS
To set the width of the left border, use the border-left-width property in CSS. You can try to run the following code to implement the border-left-width property −Example p { border-style: dashed; border-left-width: 10px; } This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo ...
Read MoreRole of CSS :enabled Selector
Use the CSS :enabled selector to style every enabled element. You can try to run the following code to implement the :enabled selector −Example input:enabled { background: blue; } Subject Student: Age:
Read MoreStyle <input> elements with a value outside a specified range with CSS
Use the CSS :out-of-range selector to style elements with a value outside a specified range.ExampleYou can try to run the following code to implement the :out-of-range selector: input:out-of-range { border: 3px dashed orange; background: yellow; } The style only works for the value entered out of range
Read MoreWhat is the keyword used in instantiating a class in Java?
An object is created from a class. In Java, the new keyword is used to create new objects. There are three steps when creating an object from a class − Declaration − A variable declaration with a variable name with an object type. Instantiation − The 'new' keyword is used to create the object. Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object. Following is an example of creating an object − Example public class Puppy { public Puppy(String name) { ...
Read MoreWhat are Floating List Items in CSS
To create a horizontal navigation bar, use the floating list item.ExampleYou can try to run the following code to create horizontal navigation bar − ul { list-style-type: none; margin: 0; padding: 0; } li { float: left; } li a { display: block; padding: 8px; background-color: orange; } Home News Contact About
Read MoreWhat are valid identifiers in Java?
A valid identifier in java – Must begin with a letter (A to Z or a to z), currency character ($) or an underscore (_). Can have any combination of characters after the first character. Cannot be a keyword. Example Following example shows various possible identifiers used to declare a variable in Java. public class VariableTest { public static void main(String args[]) { // Declaring a variable named num int num = 1; int _num = ...
Read More