Click here to Skip to main content
14,423,036 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello! I am not programmer, but I want to make a surprise for one person. I saw this code on cake to read and want to write the same, but on C#. I try to found converter of something like it in Google but falled. Can anybody help me with this? Thank you very much :)

What I have tried:

# -*- coding: utf-8 -*-

class Human(object):
def__init__(self, name, age):
self.name = name
self.age = age

def happyBirthday(self):
if self.age == 30:
print 'Happy Birthday, ', self.name, '!'

coolDude = Human('John', 30)

coolDude.happyBirthday()
Posted
Updated 28-Jun-19 9:04am
Rate this:
Please Sign up or sign in to vote.

Solution 1

public class Human
   {
   public string Name { get; private set;}
   public int Age{ get; private set;}
   public Human(string name, int age)
      {
      Name = name;
      Age = age;
      }
   public void HappyBirthday()
      {
      if (Age == 30)
         Console.WriteLine($"Happy Birthday {Name}!");
      }
   }
public static class Greetings
   {
   public static void Main()
      {
      Human coolDude = Human("John", 30);
      coolDude.HappyBirthday();
      }
   }
   
v2
Comments
Member 14474717 30-May-19 8:31am
   
Great thanks! :)
Rate this:
Please Sign up or sign in to vote.

Solution 2

def magic(number):
    return int(''.join(str(i) for i in number))

x, y=input().split()
from itertools import *
a=[int(d) for d in str(x)]
b=[int(d) for d in str(y)]
array=list(permutations(list(a)))
for i in range(len(array)):
    lis=[]
    lis=array[i]
new=[]
li=[]
magicar=[]
for i in range(len(array)):
    magicar.append(magic(array[i]))
magicar.sort()
flag=0
for i in range(len(magicar)):
    if magicar[i]>int(y):
        print(magicar[i])
        flag=1
        break
if flag==0:
    print("-1")
   
Comments
Dave Kreskowiak 28-Jun-19 14:05pm
   
If you think you're just going to dump code here and expect someone to rewrite it in C# for you, you're sorely mistaken.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100