Skip to content

Instantly share code, notes, and snippets.

using System;
namespace ConsoleApplication
{
public class Program
{
static void Main()
{
Console.WriteLine(getWithTernaryOperator());
Console.WriteLine(getWithNullCoalescingOperator());
public class Person
{
// Example 1: manually implemented property
private string _name;
public string Name
{
get
{
return _name;
public class Money
{
public decimal Amount { get; private set; } = 20m;
public void doStuff()
{
Amount *= 2;
}
}
class WhoisLookup
{
private readonly string webApiBaseAddress = "http://api.hackertarget.com/whois/?q=";
public string HostToLookup { get; private set; }
public WhoisLookup(string hostToLookup)
{
HostToLookup = hostToLookup;
}
private async void DoWhoisLookup()
{
EnableInput(false);
try
{
var googleWhoisLookup = new WhoisLookup(tbHostToLookup.Text);
// initiate HTTP request asynchronously
Task<string> getWhoisInfoTask = googleWhoisLookup.GetWhoisInformationsAsync();
using SensorDevices;
using FakeSensors;
using System;
namespace Console_SensorDevice_Test
{
static class Program
{
static void Main()
{
namespace SensorDevices
{
public interface SensorDevice : DeviceControl, DeviceState, SensorReading
{}
public interface DeviceControl
{
void powerOff();
int getFirmwareVersion();
long getSystemUptime();
interface SensorDevice
{
void powerOff();
void enable();
void disable();
bool isEnabled();
DateTime isEnabledSince();
int getFirmwareVersion();
long getSystemUptime();
int getLastReading();
[TestMethod]
public void isNonPremiumUserMailSentAndValid()
{
var user = new User("A", "A@B.com", false);
var expectedSubject = "Notification";
var expectedMessage = "Dear A this is a Notification!";
var sendMail = Mock.Create<SendMail>();
new NotificationService(sendMail).sendNotificationForUser(user);
using Core.Model;
using Core.Services;
using Infrastucture.Services;
using System;
namespace UserEMailNotificationSender
{
public class Program
{
static void Main(string[] args)