- 1
Тип объекта, который инициализируется безумно.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Тип объекта, который инициализируется безумно.
https://learn.microsoft.com/ru-ru/dotnet/api/system.lazy-1?view=net-8.0#--------------
Обожаю автоматический перевод в документации
В оригинале, кстати, вот так:
https://learn.microsoft.com/en-us/dotnet/api/system.lazy-1?view=net-8.0#type-parameters
Заметьте, что ссылка тоже побилась
0
private void UpdateRowInfo()
{
//код
if (condition);
{
//код
}
//код
}
Наткнулся на вот такое в одном проекте. Точка с запятой после if считается пустым statement, а всё что внутри фигурных скобок - просто блок, от if'а независящий. Всё, как IDEшка об этом сообщает - точка с запятой стала серого цвета (на сером фоне, ага). Угадайте, сколько времени искался этот баг
+1
/// <summary>
/// перобразуем DateTime? в DateTime, если не получается, то возвращаем текущую дату
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private DateTime DateTimeHelper(DateTime? date)
{
try
{
return (DateTime)date;
}
catch
{
return DateTime.Now;
}
}
0
string[] words = line.Split(' ');
foreach (var word in words)
{
Console.Write(word);
switch (word)
{
case "11":
Console.WriteLine($"{tableEng[0, 0]}");
break;
case "12":
Console.WriteLine($"{tableEng[0, 1]}");
break;
case "13":
Console.WriteLine($"{tableEng[0, 2]}");
break;
case "14":
Console.WriteLine($"{tableEng[0, 3]}");
break;
case "15":
Console.WriteLine($"{tableEng[0, 4]}");
break;
case "21":
Console.WriteLine($"{tableEng[1, 0]}");//
break;
case "22":
Console.WriteLine($"{tableEng[1, 1]}");
break;
case "23":
Console.WriteLine($"{tableEng[1, 2]}");
break;
case "24":
Console.WriteLine($"{tableEng[1, 3]}");
break;
case "25":
Console.WriteLine($"{tableEng[1, 4]}");
break;
case "31":
Console.WriteLine($"{tableEng[2, 0]}");
break;
case "32":
Console.WriteLine($"{tableEng[2, 1]}");
break;
case "33":
Console.WriteLine($"{tableEng[2, 2]}");
break;
case "34":
Console.WriteLine($"{tableEng[2, 3]}");
break;
case "35":
Console.WriteLine($"{tableEng[2, 4]}");
break;
case "41":
Console.WriteLine($"{tableEng[3, 0]}");
break;
case "42":
Console.WriteLine($"{tableEng[3, 1]}");
break;
case "43":
Console.WriteLine($"{tableEng[3, 2]}");
break;
case "44":
Console.WriteLine($"{tableEng[3, 3]}");
break;
case "45":
Console.WriteLine($"{tableEng[3, 4]}");
break;
case "51":
Console.WriteLine($"{tableEng[4, 0]}");
break;
case "52":
Console.WriteLine($"{tableEng[4, 1]}");
break;
case "53":
Console.WriteLine($"{tableEng[4, 2]}");
break;
case "54":
Console.WriteLine($"{tableEng[4, 3]}");
break;
case "55":
Console.WriteLine($"{tableEng[4, 4]}");
break;
}
}
}
Console.ReadLine();
Дело IsBukva живёт.
https://habr.com/ru/articles/771530/
0
public readonly struct Int64 : IComparable<long>, IConvertible,
IEquatable<long>, IParsable<long>, ISpanParsable<long>,
System.Numerics.IAdditionOperators<long,long,long>,
System.Numerics.IAdditiveIdentity<long,long>,
System.Numerics.IBinaryInteger<long>, System.Numerics.IBinaryNumber<long>,
System.Numerics.IBitwiseOperators<long,long,long>,
System.Numerics.IComparisonOperators<long,long,bool>,
System.Numerics.IDecrementOperators<long>,
System.Numerics.IDivisionOperators<long,long,long>,
System.Numerics.IEqualityOperators<long,long,bool>,
System.Numerics.IIncrementOperators<long>,
System.Numerics.IMinMaxValue<long>,
System.Numerics.IModulusOperators<long,long,long>,
System.Numerics.IMultiplicativeIdentity<long,long>,
System.Numerics.IMultiplyOperators<long,long,long>,
System.Numerics.INumber<long>, System.Numerics.INumberBase<long>,
System.Numerics.IShiftOperators<long,int,long>,
System.Numerics.ISignedNumber<long>,
System.Numerics.ISubtractionOperators<long,long,long>,
System.Numerics.IUnaryNegationOperators<long,long>,
System.Numerics.IUnaryPlusOperators<long,long>
https://learn.microsoft.com/en-us/dotnet/api/system.int64?view=net-7.0
0
public ArgumentException (string? message, string? paramName);
public ArgumentNullException (string? paramName, string? message);
https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception.-ctor?view=net-7.0#system-argumentexception-ctor(system-string-system-string)
https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception.-ctor?view=net-7.0#system-argumentnullexception-ctor(system-string-system-string)
+1
using System;
using System.Linq;
namespace TheBestGenerator
{
class Symbols
{
protected const string Letters = "abcdefghijklmnopqrstuvwxyz";
protected const string Numbers = "0123456789";
protected const string DefaultSpecialSymbols = @"!#$%&*@\";
protected static Random rand = new Random();
}
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Введите длину пароля:");
int Len = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(Generator.Password(Len));
}
}
}
class Generator: Symbols
{
static char[] Array_()
{
return (Numbers+Letters+Letters.ToUpper()+DefaultSpecialSymbols).ToCharArray();
}
static char[] Password_Symbols()
{
return Array_().OrderBy(Symbol => rand.Next()).ToArray();
}
public static string Password(int Len )
{
char[] password = Password_Symbols();
Array.Resize(ref password, Len);
return (string.Join("", password));
}
}
}
Генератор паролей. Говнокод с наследованием. Почти ничего не понимаю в нем, но "прогу" с ним написал.
0
public class Archvile:Actor{public Archvile(){Health=700;Radius=20;Height=56;Mass=500;Speed=15;PainChance=10;Monster=true;MaxTargetRange=896;SetFlag(Flags.QUICKTORETALIATE,true);SetFlag(Flags.FLOORCLIP,true);SetFlag(Flags.NOTARGET,true);SeeSound="vile/sight";PainSound="vile/pain";DeathSound="vile/death";ActiveSound="vile/active";MeleeSound="vile/stop";Obituary="$OB_VILE";Tag="$FN_ARCH";}
public override void BeginPlay(){base.BeginPlay();SetState("Spawn");}
void Spawn(){SetState("See");}
void See(){A_Chase();}
void Missile(){A_VileStart();A_FaceTarget();A_VileTarget();A_FaceTarget();A_VileAttack();Delay(20);SetState("See");}
void Heal(){Delay(10);SetState("See");}
void Pain(){A_Pain();SetState("See");}
void Death(){A_Scream();A_NoBlocking();Delay(7);SetState("Death 1");}
void Death1(){Delay(7);SetState("Death 2");}
void Death2(){Delay(7);SetState("Death 3");}
void Death3(){Delay(7);SetState("Death 4");}
void Death4(){Delay(7);SetState("Death 5");}
void Death5(){Delay(7);SetState("Death 6");}
void Death6(){Delay(7);SetState("Death 7");}
void Death7(){Delay(1);Destroy();}
void A_VileStart(){StartSound("vile/start",CHAN_VOICE);}
void A_VileTarget(){if(target!=null){A_FaceTarget();Actor fog=Spawn<Actor>("ArchvileFire",target.Pos,SpawnFlags.ALLOW_REPLACE);if(fog!=null){tracer=fog;fog.target=self;fog.tracer=self.target;fog.A_Fire(0);}}}
void A_VileAttack(){Actor targ=target;if(targ!=null){A_FaceTarget();if(!CheckSight(targ,0))return;StartSound("vile/stop",CHAN_WEAPON);int newdam=targ.DamageMobj(self,self,20,DamageType.none);if(newdam>0)targ.TraceBleed(newdam,self);Actor fire=tracer;if(fire!=null){fire.SetOrigin(targ.Vec3Angle(-24.0,angle,0),true);fire.A_Explode(70,70,ExplosionFlags.XF_NOSPLASH,false,0,0,0,"BulletPuff",DamageType.Fire);}
if(!targ.bDontThrust){targ.Vel.z=1000.0*thrust/Math.Max(1,targ.Mass);}}}
void A_StartFire(){StartSound("vile/firestrt",CHAN_BODY);A_Fire();}
void A_Fire(){Actor dest=tracer;if(dest==null||target==null)return;if(!target.CheckSight(dest,0))return;SetOrigin(dest.Vec3Angle(24,dest.angle,0),true);}
void A_FireCrackle(){StartSound("vile/firecrkl",CHAN_BODY);A_Fire();}}
public static class ActorExtensions{public static void A_VileStart(this Actor self){self.StartSound("vile/start",CHAN_VOICE);}
public static void A_VileTarget(this Actor self,string fire="ArchvileFire"){if(self.target!=null){self.A_FaceTarget();Actor fog=self.Spawn<Actor>(fire,self.target.Pos,SpawnFlags.ALLOW_REPLACE);if(fog!=null){self.tracer=fog;fog.target=self;fog.tracer=self.target;fog.A_Fire(0);}}}
public static void A_VileAttack(this Actor self,string snd="vile/stop",int initialdmg=20,int blastdmg=70,int blastradius=70,double thrust=1.0,string damagetype="Fire",int flags=0){Actor targ=self.target;if(targ!=null){self.A_FaceTarget();if(!self.CheckSight(targ,0))return;self.StartSound(snd,CHAN_WEAPON);int newdam=targ.DamageMobj(self,self,initialdmg,(flags
Арчвайл из ZDooM на C#
0
protected override Detail GetDetailPage(
aggregate aggregate,
int cashbackRate,
BannerResponse bannerInfo,
List<MediaShortResponse> mediaInfo,
EntityFavourites likeCountInfo,
List<FavouriteEntity> likeInfo)
{
var announcementDetail = new Detail
(
aggregate.Details.Id,
aggregate.Details.Alias,
aggregate.Details.Title,
aggregate.Details.Description,
aggregate.Details.DescriptionShortcut,
aggregate.Details.Age,
aggregate.ExtendedDetails.DataSourceId,
aggregate.ExtendedDetails.DataSourceItemId,
cashbackRate,
null,
aggregate.ExtendedDetails.LastEventDateTime,
aggregate.ExtendedDetails.EventClosestDateTime,
aggregate.ExtendedDetails.Url,
aggregate.ExtendedDetails.Category != null
? new AnnouncementCategory(aggregate.ExtendedDetails.Category.Id,
aggregate.ExtendedDetails.Category.Title,
aggregate.ExtendedDetails.Category.Url)
: null,
aggregate.ExtendedDetails.Tags?.Select(ss =>
new Tag(ss.Title, HttpUtility.UrlPathEncode(ss.Url))
).ToList(),
aggregate.Details.Privileges?.Select(ss => new Privilege()
{
Description = ss.Description,
Id = ss.Id,
ImageUrl = ss.ImageUrl.ToString(),
Title = ss.Title
}).ToList(),
mediaInfo.Select(m => new Media
{
Type = m.Type,
Url = m.Url
}).ToList(),
aggregate.ExtendedDetails.EventMinPrice,
likeInfo.FirstOrDefault(x => x.EntityId == aggregate.Details.Id)?.IsSet ?? false,
likeCountInfo?.TotalCount,
aggregate.ExtendedDetails.Promotext,
bannerInfo != null ? new Banner { Url = bannerInfo.Url, ImageUrl = bannerInfo.ImageUrl } : null,
aggregate.Details.Venue != null
? new ShortVenue(aggregate.Details.Venue.Id,
aggregate.Details.Venue.Title,
aggregate.Details.Venue.Url.Replace(_liveBaseAddress, ""),
aggregate.Details.Venue.Address)
: null,
(AnnouncementStatus)aggregate.Details.Status,
aggregate.ExtendedDetails.PremiumRule,
aggregate.Details.HasPrivilegeEnabled,
);
return announcementDetail;
}
0
class StargateSimulator
{
static bool shieldEnabled = false;
static void Main()
{
Console.WriteLine("Stargate Simulator");
Console.WriteLine("------------------");
// Check for zero point module
Console.Write("Zero Point Module detected. Proceed with simulation? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Simulation cancelled.");
return;
}
// Enable shield
Console.Write("Enable gate shield? (y/n) ");
response = Console.ReadLine();
if (response.ToLower() == "y")
{
EnableShield();
}
// Enter gate address
Console.Write("Enter gate address: ");
string address = Console.ReadLine();
if (address.Length != 6 && address.Length != 8)
{
Console.WriteLine("Invalid address length.");
return;
}
// Dial gate
Dial(address);
Console.WriteLine("Simulation complete.");
}
static void Dial(string address)
{
// Check for valid address
if (address.Length != 6 && address.Length != 8)
{
Console.WriteLine("Invalid address length.");
return;
}
// Check for energy source
Console.Write("Energy source detected. Proceed with dialing? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Dialing cancelled.");
return;
}
// Dial gate
Console.WriteLine("Dialing gate...");
if (shieldEnabled)
{
Console.WriteLine("Gate shield is active.");
}
Console.WriteLine("Chevron 1 encoded.");
Console.WriteLine("Chevron 2 encoded.");
Console.WriteLine("Chevron 3 encoded.");
Console.WriteLine("Chevron 4 encoded.");
Console.WriteLine("Chevron 5 encoded.");
Console.WriteLine("Chevron 6 encoded.");
if (address.Length == 8)
{
Console.WriteLine("Chevron 7 encoded.");
Console.WriteLine("Gate engaged.");
}
else
{
Console.WriteLine("Gate engaged.");
}
}
static void EnableShield()
{
// Check for available power
Console.Write("Power levels stable. Activate gate shield? (y/n) ");
string response = Console.ReadLine();
if (response.ToLower() != "y")
{
Console.WriteLine("Shield activation cancelled.");
return;
}
// Activate shield
Console.WriteLine("Shield activated.");
shieldEnabled = true;
}
}
Симулятор наборного устройства звездных врат.
P.S. За Канон-френдли не отвечаю, т.к. фанат серии но любитель немножко поизвращаться над ЛОРом...