Karthikeya Boyini has Published 2383 Articles

C# Program to change a character from a string

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:35:34

217 Views

Let's say our string is −StringBuilder str = new StringBuilder(); str.Append("pre");To change a character, set the value at that particular index. The following sets a character at the 3rd position −str[2] = 'o';Here is the complete code −Example Live Demousing System; using System.Text; public class Demo {    public static ... Read More

How can we update any value in MySQL view as we can update the values in MySQL table?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:32:30

372 Views

As we know that with the help of UPDATE statement we can update the values in MySQL table and in the similar way we can update the values in MySQL views. The syntax of UPDATE statement would be the same except at the place of table name we have to ... Read More

C# program to determine if Two Words Are Anagrams of Each Other

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:25:04

6K+ Views

For anagram, another string would have the same characters present in the first string, but the order of characters can be different.Here, we are checking the following two strings −string str1 = "heater"; string str2 = "reheat";Convert both the strings into character array −char[] ch1 = str1.ToLower().ToCharArray(); char[] ch2 = ... Read More

C# program to find if an array contains duplicate

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:24:00

1K+ Views

Set an array −int[] arr = {    89,    12,    56,    89, };Now, create a new Dictionary −var d = new Dictionary < int, int > ();Using the dictionary method ContainsKey(), find the duplicate elements in the array −foreach(var res in arr) {    if (d.ContainsKey(res))   ... Read More

How to compute Average for the Set of Values using C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:13:36

187 Views

Firstly, set an array with values −int[] myArr = new int[] {    34,    23,    77,    67 };To get the average, firstly get the sum of array elements.Divide the sum with the length of the array and that will give you the average of the elements −int ... Read More

How to Convert Hex String to Hex Number in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:04:03

1K+ Views

Firstly, set the Hex String −string str = "7D";Now, use the Convert.ToSByte() method to convert the Hex string to Hex number −Console.WriteLine(Convert.ToSByte(str, 16));Let us see the complete code −Example Live Demousing System; namespace Demo {    public class Program {       public static void Main(string[] args) {   ... Read More

C# program to check whether a given string is Heterogram or not

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 13:03:33

297 Views

Heterogram for a string means the string isn’t having duplicate letters. For example −Mobile Cry LaptopLoop through each word of the string until the length of the string −for (int i = 0; i < len; i++) {    if (val[str[i] - 'a'] == 0)    val[str[i] - 'a'] = ... Read More

Foreach in C++ and C#

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 12:57:28

556 Views

Foreach in C++C++ 11 introduced foreach loop to traverse over each element. Here is an example −Example Live Demo#include using namespace std; int main() {    int myArr[] = { 99, 15, 67 };    // foreach loop    for (int ele : myArr)    cout

C# program to check for a string that contains all vowels

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 12:55:59

384 Views

To check for all vowels, firstly set the condition to check −string res = str.Where(chk =< "aeiouAEIOU".Contains(chk)).Distinct();Above, we have used the string −string str = "the quick brown fox jumps over the lazy dog";Now, using the Any() method checks whether the string has any vowels or not −if(!res.Any()) Console.WriteLine("No vowels!");Loop ... Read More

What are the limitations of using MySQL views?

karthikeya Boyini

karthikeya Boyini

Updated on 22-Jun-2020 12:55:02

1K+ Views

In spite of various benefits of using views there are following limitations on using MySQL views − Can’t create an index of views − In MySQL, we cannot create an index on views. It is because indexes are not utilized when we query data against the views. MySQL invalidates the view − ... Read More

Advertisements