radhakrishna

radhakrishna

62 Articles Published

Articles by radhakrishna

62 articles

How to get last 4 characters from string innC#?

radhakrishna
radhakrishna
Updated on 17-Mar-2026 3K+ Views

Getting the last 4 characters from a string in C# is a common task that can be accomplished using the Substring() method. This method extracts a portion of the string based on the starting position and length specified. Syntax Following is the syntax for using Substring() to get the last characters − string.Substring(startIndex) string.Substring(startIndex, length) To get the last 4 characters, calculate the starting position as − str.Substring(str.Length - 4) Using Substring() Method The Substring() method extracts characters from a specified starting position to the end of the string. ...

Read More

How to set a value to the element at the specified position in the one-dimensional array in C#

radhakrishna
radhakrishna
Updated on 17-Mar-2026 407 Views

In C#, you can set a value to an element at a specific position in a one-dimensional array using the array indexing operator []. Array indexing in C# is zero-based, meaning the first element is at index 0, the second at index 1, and so on. Syntax Following is the syntax for setting a value to an array element at a specified position − arrayName[index] = value; Where index is the position (starting from 0) and value is the new value to be assigned. Using Array Index Assignment First, declare and initialize ...

Read More

Exit Methods in C# Application

radhakrishna
radhakrishna
Updated on 17-Mar-2026 12K+ Views

In C# applications, there are several methods to exit or terminate the application. Each method serves different purposes and has specific use cases. Understanding when and how to use each exit method is crucial for proper application lifecycle management. Environment.Exit() Method The Environment.Exit() method terminates the entire process and returns an exit code to the operating system. This is the most common way to exit a console application. Syntax Environment.Exit(exitCode); The exitCode parameter indicates the success or failure status − 0 − Indicates successful completion Non-zero values − ...

Read More

How do we include the legal number intervals for an input field in HTML?

radhakrishna
radhakrishna
Updated on 16-Mar-2026 361 Views

The step attribute in HTML defines the legal number intervals for input fields. It specifies the increment value that users can select, creating a controlled range of acceptable values. The step attribute works with numeric input types like number, range, date, datetime-local, month, time, and week. Syntax Following is the syntax for the step attribute − The value can be a positive number, decimal, or the keyword any. When combined with min and max attributes, it creates a complete range validation system. Step Attribute with Number Input The step attribute controls ...

Read More

How to save HTML Canvas as an Image with canvas.toDataURL()?

radhakrishna
radhakrishna
Updated on 16-Mar-2026 1K+ Views

The HTML5 Canvas provides the toDataURL() method to export canvas drawings as image data URLs. This method converts the canvas content into a base64-encoded data URL, typically in PNG format, which can be used to save, display, or download the canvas as an image file. Syntax Following is the syntax for the toDataURL() method − canvas.toDataURL(type, encoderOptions) Parameters type (optional) − A string indicating the image format. Default is "image/png". Other supported formats include "image/jpeg" and "image/webp". encoderOptions (optional) − A number between 0 and 1 indicating image quality ...

Read More

Change colour of an image drawn on an HTML5 canvas element.

radhakrishna
radhakrishna
Updated on 16-Mar-2026 2K+ Views

In order to change the color of an image drawn on an HTML5 Canvas element, you need to manipulate the pixel data of the image. This is achieved by using the drawImage() method to draw the image onto the canvas, then accessing and modifying the pixel data using getImageData() and putImageData() methods. Syntax Following is the syntax for drawing an image on canvas − ctx.drawImage(image, x, y); Following is the syntax for getting image data − var imageData = ctx.getImageData(x, y, width, height); Following is the syntax for putting modified ...

Read More

Execute a script when a mouse button is released over an element in HTML?

radhakrishna
radhakrishna
Updated on 16-Mar-2026 284 Views

When a mouse button is released over an HTML element, the onmouseup event is triggered. This event is commonly used for creating interactive elements that respond to mouse clicks and releases. The onmouseup attribute can be added to any HTML element to execute JavaScript code when the user releases a mouse button while the cursor is over that element. Syntax Following is the syntax for the onmouseup event attribute − Content Where script is the JavaScript code that executes when the mouse button is released over the element. How It Works The ...

Read More

Usage of white-space property in CSS

radhakrishna
radhakrishna
Updated on 15-Mar-2026 108 Views

The CSS white-space property controls how whitespace characters (spaces, tabs, line breaks) are handled within an element. It determines whether text wraps, how spaces are collapsed, and whether line breaks are preserved. Syntax white-space: normal | nowrap | pre | pre-wrap | pre-line | break-spaces; White-space Values Value Spaces Collapsed? Line Breaks Honored? Text Wraps? normal Yes No Yes nowrap Yes No No pre No Yes No pre-wrap No Yes Yes pre-line Yes Yes Yes Example: Using white-space: pre ...

Read More

How do we upload external file on a website using HTML forms?

radhakrishna
radhakrishna
Updated on 15-Mar-2026 5K+ Views

If you want to allow a user to upload an external file to your website, you need to use a file upload box, also known as a file select box. This is created using the element with the type attribute set to file. HTML File Upload Form Choose file... Browse No file chosen Basic File Upload Example Here's a simple HTML form with a file upload input: File ...

Read More

Universal Selectors in CSS

radhakrishna
radhakrishna
Updated on 15-Mar-2026 772 Views

The universal selector in CSS is represented by an asterisk (*) and matches every element in an HTML document. Unlike type selectors that target specific tags like h1 or p, the universal selector applies styles to all elements at once. Type Selector vs Universal Selector Type selectors target specific HTML elements: h2 { color: #FFFF00; } The universal selector targets all elements: * { color: #FFFF00; } Example: Universal Selector in Action ...

Read More
Showing 1–10 of 62 articles
« Prev 1 2 3 4 5 7 Next »
Advertisements