Determine If a String Has All Unique Characters in C#

George John
Updated on 23-Jun-2020 11:34:36

3K+ Views

Use the substring() method in C# to check each and every substring for unique characters. Loop it until the length of the string.If any one the substring matches another, then it would mean that the string do not have unique characters.You can try to run the following code to determine if a string has all unique characters.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class Demo {    public bool CheckUnique(string str) {       string one = "";       string two = "";       for (int i = 0; i ... Read More

HTML DOM meter Value Property

AmitDiwan
Updated on 23-Jun-2020 11:34:07

134 Views

The HTML DOM Meter value property returns/sets a number corresponding to the value attribute of a element. Use this with high, low, min and max attributes for better results.NOTE: Don’t use as a progress bar but only as a gauge.Following is the syntax −Returning value of the value propertymeterElementObject.valueValue of the value property setmeterElementObject.value = numberLet us see an example of Meter value property −Example Live Demo Meter value    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px; ... Read More

C# Program to Sort an Array in Descending Order

Samual Sam
Updated on 23-Jun-2020 11:33:39

4K+ Views

Initialize the array.int[] myArr = new int[5] {98, 76, 99, 32, 77};Compare the first element in the array with the next element to find the largest element, then the second largest, etc.if(myArr[i] < myArr[j]) {    temp = myArr[i];    myArr[i] = myArr[j];    myArr[j] = temp; }Above, i and j are initially set to.i=0; j=i+1;Try to run the following code to sort an array in descending order.Example Live Demousing System; public class Demo {    public static void Main() {       int[] myArr = new int[5] {98, 76, 99, 32, 77};       int i, j, temp;       Console.Write("Elements: ");       for(i=0;i

Purpose of as Operator in C#

Chandu yadav
Updated on 23-Jun-2020 11:32:35

202 Views

The "as" operator perform conversions between compatible types. It is like a cast operation and it performs only reference conversions, nullable conversions, and boxing conversions. The as operator can't perform other conversions, such as user-defined conversions, which should instead be performed by using cast expressions.The following is an example showing the usage of as operation in C#. Here as is used for conversion.string s = obj[i] as string;Try to run the following code to work with ‘as’ operator in C#.Example Live Demousing System; public class Demo {    public static void Main() {       object[] obj = new object[2]; ... Read More

Set CSS Property for Transition Effect with JavaScript

Nitya Raut
Updated on 23-Jun-2020 11:30:59

167 Views

Use the transitionProperty in JavaScript to set the CSS property. You can try to run the following code to return the CSS property that the transition effect is for with JavaScript −Example                    #div1 {             position: relative;             margin: 10px;             height: 300px;             width: 400px;             padding: 20px;             border: 2px solid blue;          }          #div2 {             padding: 80px;             position: absolute;             border: 2px solid BLUE;             background-color: yellow;             transform: rotateY(45deg);             transition: all 3s;          }          #div2:hover {             background-color: orange;             width: 50px;             height: 50px;             padding: 100px;             border-radius: 50px;          }                     Hover over DIV2       Set       DIV1          DIV2                      function display() {             document.getElementById("div2").style.transitionProperty = "width,height";          }          

Scope of a Private Member Variable in C#

Chandu yadav
Updated on 23-Jun-2020 11:29:11

439 Views

Only functions of the same class can access its private members. Private access specifier allows a class to hide its member variables and member functions from other functions and objects.Example Live Demousing System; namespace RectangleApplication {    class Rectangle {       //member variables       private double length;       private double width;       public void Acceptdetails() {          length = 10;          width = 14;       }       public double GetArea() {          return length * width;       } ... Read More

Set Horizontal Alignment of Text with JavaScript

Srinivas Gorla
Updated on 23-Jun-2020 11:28:55

815 Views

Use the textAlign property in JavaScript and set it to right for aligning it horizontally. You can try to run the following code to return the horizontal alignment of text with JavaScript −Example           This is demo text       Set Horizontal Alignment                function display() {             document.getElementById("myText").style.textAlign = "right";          }          

Align Last Line Before Forced Line Break with Justify Text in JavaScript

Smita Kapse
Updated on 23-Jun-2020 11:28:24

383 Views

Use the textAlignLast property in JavaScript to set the last line to right. Set it to right and allow the right alignment.ExampleYou can try to run the following code to return how the last line of a block or a line right before a forced line break is aligned when text-align is "justify" with JavaScript −                    #myDIV {             text-align: justify;          }                              This is ... Read More

Initialize Two-Dimensional Arrays in C#

Arjun Thakur
Updated on 23-Jun-2020 11:28:14

24K+ Views

A 2-dimensional array is a list of one-dimensional arrays.Two-dimensional arrays may be initialized by specifying bracketed values for each row.int [,] a = new int [4,4] {    {0, 1, 2, 3} ,    {4, 5, 6, 7} ,    {8, 9, 10, 11} ,    {12, 13, 14, 15} };The following is an example showing how to work with two-dimensional arrays in C#.Example Live Demousing System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          /* an array with 3 rows and 2 columns*/          int[,] a = new int[3, 2] {{0,0}, {1,2}, {2,4} };          int i, j;          /* output each array element's value */          for (i = 0; i < 3; i++) {             for (j = 0; j < 2; j++) {                Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i,j]);             }          }          Console.ReadKey();       }    } }Outputa[0,0] = 0 a[0,1] = 0 a[1,0] = 1 a[1,1] = 2 a[2,0] = 2 a[2,1] = 4

Set Text Decoration with JavaScript

Nikitha N
Updated on 23-Jun-2020 11:27:38

946 Views

Use the textDecoration property in JavaScript to decorate the text. You can underline a text using this property.ExampleYou can try to run the following code to set the decoration of a text with JavaScript −           This is demo text.       Set Text Decoration                function display() {             document.getElementById("myText").style.textDecoration = "underline";          }          

Advertisements