Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.22/5 (4 votes)
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 29-Jul-21 6:38am
v2

1 solution

C#
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();
      }
   }
 
Share this answer
 
v2
Comments
Member 14474717 30-May-19 8:31am    
Great thanks! :)
Member 14848338 17-Jun-20 11:25am    
import numpy as np
import pandas as pd
import random as rd
from random import randint
import matplotlib.pyplot as plt
item_number = np.arange(1,11)
weight = np.random.randint(1, 15, size = 10)
value = np.random.randint(10, 750, size = 10)
knapsack_threshold = 35 #Maximum weight that the bag of thief can hold
print('The list is as follows:')
print('Item No. Weight Value')
for i in range(item_number.shape[0]):
print('{0} {1} {2}\n'.format(item_number[i], weight[i], value[i]))
OriginalGriff 17-Jun-20 11:55am    
Why have you posted this?
Tony Hill 18-Nov-20 14:59pm    
Completely unrelated nonsense to the original posters question.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900