Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# palidrone

//Palindrome = word that reads the same forward as it does backward
public static void Main(string[] args)
        {
            Console.WriteLine(new Program().Pal("AsdsA"));
        }
        public bool Pal(string str) 
		{
            int end = str.Length-1;

            for (int i = 0, j = end; i < end; i++, j--)
            {
                char frontLetter = str[i];	//Char.ToLower(str[i]);
                char endLetter = str[j];	//Char.ToLower(str[i]);

                if (frontLetter != endLetter) return false;
            }   
            return true;
        }        
---------------------------------------------------------Option1

public bool Pal(string str) 
        {
            char[] rev = str.ToCharArray();
            Array.Reverse(rev);
            string reversed = new string(rev);

            //if ( str.Equals(reversed, StringComparison.OrdinalIgnoreCase)  ) return true;

            if (str.Equals(reversed)) return true;

            else return false;        
        }        
----------------------------------------------------------Option2
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to change loaded scene in unity 
Csharp :: unity button press onclick click add C# 
Csharp :: c# relative path to project folder 
Csharp :: milliseconds to seconds c# 
Csharp :: singleton unity 
Csharp :: get execution directory c# 
Csharp :: make invisible unity 
Csharp :: initialize ConsoleLoggerProvider in EF core 
Csharp :: color picker wpf 
Csharp :: how to make a specific scene load only on game start in unity 
Csharp :: tostring tmpro unity 
Csharp :: open folder dialog c# 
Csharp :: c# find duplicates in list of strings 
Csharp :: convert ienumerable to list 
Csharp :: c# 
Csharp :: c# get enum value from string 
Csharp :: c# foreach char in string 
Csharp :: c# string array to string 
Csharp :: c# regex get matched string 
Csharp :: c# first item i list 
Csharp :: unity vscode no autocomplete 
Csharp :: c# unity detect any keyboard input 
Csharp :: c# read file 
Csharp :: serilog set log level 
Csharp :: c# how to sort a list 
Csharp :: get type of variable c# 
Csharp :: c# use hashtable check if key exists 
Csharp :: unity overlapsphere 
Csharp :: unity cast int to float 
Csharp :: unity call function on animation finish 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =