Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Day 2 codes in C# #366

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
<td align="center"><a href="https://github.com/gaurav01k3"><img src="https://avatars0.githubusercontent.com/u/67451786?v=4?s=100" width="100px;" alt=""/><br /><sub><b>GAURAV KUMAR</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=gaurav01k3" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=gaurav01k3" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/wboccard"><img src="https://avatars3.githubusercontent.com/u/72316984?v=4?s=100" width="100px;" alt=""/><br /><sub><b>wboccard</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=wboccard" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=wboccard" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/d-l-mcbride"><img src="https://avatars3.githubusercontent.com/u/46550732?v=4?s=100" width="100px;" alt=""/><br /><sub><b>d-l-mcbride</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/senbagaraman04><img src="https://avatars3.githubusercontent.com/u/6167701?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Senbagaraman</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=senbagaraman04 title="Documentation">📖</a> <a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/mihirg008"><img src="https://avatars3.githubusercontent.com/u/32246337?s=460&u=26abf142607d487660a12fcc8b508407b0896c8c&v=4" width="100px;" alt=""/><br /><sub><b>mihirg008</b></sub></a><br /><a href="https://github.com/CodeToExpress/dailycodebase/commits?author=d-l-mcbride" title="Documentation">📖</a></td>

</tr>
</table>

Expand Down
31 changes: 31 additions & 0 deletions Day2/C#/StringReverse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
*
* @author: Senbagaraman Manoharan
* @date: 19th October 2020
*
* Given a string, write a program to return a new string with reversed order of characters
*
* */
using System;
using System.Collections.Generic;
using System.Reflection;

public class Program
{

public static void Main()
{
string enteredString, rvrString = "";
int stringLength;
Console.Write("The string to be reversed: ");
enteredString = Console.ReadLine();
stringLength = enteredString.Length - 1;
while (stringLength >= 0)
{
rvrString = rvrString + enteredString[Length];
stringLength--;
}
Console.WriteLine("The reversed string is {0}", rvrString);
Console.ReadLine();
}
}
41 changes: 41 additions & 0 deletions Day2/C#/palindrome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
*
* @author: Senbagaraman Manoharan
* @date: 19th October 2020
*
* Given a string, write a funcation which prints whether the given string is palindrome or nor
*
* */
using System;
using System.Collections.Generic;
using System.Reflection;

public class Program
{

public static void Main()
{
string enteredString, rvrString = "";
int stringLength;
Console.Write("The string to be checked: ");
enteredString = Console.ReadLine();
stringLength = enteredString.Length - 1;
while (stringLength >= 0)
{
rvrString = rvrString + enteredString[Length];
stringLength--;
}
Console.WriteLine("The reversed string is {0}", rvrString);

if(enteredString.Equals(rvrString))
{
Console.WriteLine("The given string is palindrome");
}
else
{
Console.WriteLine("The given string is not palindrome");
}

Console.ReadLine();
}
}
90 changes: 89 additions & 1 deletion Day2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void main(){

### [reverse.rb](./Ruby/reverse.rb)

```ruby
```c#
=begin
@author: aaditkamat
@date: 22/12/2018
Expand Down Expand Up @@ -555,6 +555,47 @@ def long_solution_recursive(str)
end
```



## C# Implementation

### [StringReverse.cs](./C#/StringReverse.cs)

```c#
/**
*
* @author: Senbagaraman Manoharan
* @date: 19th October 2020
*
* Given a string, write a program to return a new string with reversed order of characters
*
* */
using System;
using System.Collections.Generic;
using System.Reflection;

public class Program
{

public static void Main()
{
string enteredString, rvrString = "";
int stringLength;
Console.Write("The string to be reversed: ");
enteredString = Console.ReadLine();
stringLength = enteredString.Length - 1;
while (stringLength >= 0)
{
rvrString = rvrString + enteredString[Length];
stringLength--;
}
Console.WriteLine("The reversed string is {0}", rvrString);
Console.ReadLine();
}
}
```


<hr />

## Part B -- Palindrome Check
Expand Down Expand Up @@ -981,6 +1022,53 @@ public class StringReverseAndPalin {
}
```

## C# implementation

### [palindrome.cs](./C#/palindrome.cs)
```C#
/**
*
* @author: Senbagaraman Manoharan
* @date: 19th October 2020
*
* Given a string, write a funcation which prints whether the given string is palindrome or nor
*
* */
using System;
using System.Collections.Generic;
using System.Reflection;

public class Program
{

public static void Main()
{
string enteredString, rvrString = "";
int stringLength;
Console.Write("The string to be checked: ");
enteredString = Console.ReadLine();
stringLength = enteredString.Length - 1;
while (stringLength >= 0)
{
rvrString = rvrString + enteredString[Length];
stringLength--;
}
Console.WriteLine("The reversed string is {0}", rvrString);

if(enteredString.Equals(rvrString))
{
Console.WriteLine("The given string is palindrome");
}
else
{
Console.WriteLine("The given string is not palindrome");
}

Console.ReadLine();
}
}
```

### Have Another solution?

The beauty of programming lies in the fact that there is never a single solution to any problem.
Expand Down