Skip to main content

All Questions

Tagged with
0 votes
3 answers
91 views

Inheritance of C# functions and using reusability

I'm drawing a complete blank on what to actually call what I want to do (hence the difficulty I am having in trying to research it). But what I do have is this: public interface IShapes { public ...
John Barber's user avatar
0 votes
0 answers
14 views

Declaring an interface property as a derived type [duplicate]

Currently I have a series of services/repos that are allowing a generic of a custom type. I want to add a generic list to that interface such that when a class inherits the interface it can apply a ...
Ian's user avatar
  • 71
-2 votes
0 answers
55 views

a constructer declared in a type with parametere list must have 'this' constructor inisializer error [closed]

I'm working on a C# project where I have an abstract base class Employee with a parameterized constructor Employee(string name). My derived class FullTimeEmployee has a constructor that takes three ...
Smoker's user avatar
  • 1
0 votes
0 answers
44 views

How to alter WPF button color from the Code not user input (click) [closed]

I have a WPF application that allows users to pick a test to run. We have 3 tests called Test1, Test2 and Test3. All these tests inherit a model called TestModel. TestMoel contains common properties ...
varun's user avatar
  • 1
1 vote
0 answers
29 views

Complex multi level EF Core 8 inheritance issue

Please consider the following: DB Context: // DbContext.cs public partial class OperationsDbContext : DbContext { public virtual DbSet<AnimalBase> AnimalBases { get; set; } public virtual ...
Mejenborg's user avatar
0 votes
1 answer
58 views

Provide implementation for an abstract method from an interface

Is it possible to override a method implementation by deriving from an interface which gives a default implementation for that method? If not, how should I restructure my code to avoid explicit method ...
Elia Giaccardi's user avatar
2 votes
2 answers
88 views

How to declare a function parameter to accept all derived types of a generic abstract type?

these are base type [DataContract] public abstract class InputModelBase<T>where T : InputModelParametersBase { [DataMember] public string Token { get; set; } [DataMember] public ...
FDB's user avatar
  • 1,055
0 votes
0 answers
24 views

Automapper mapping to derived type based on predicate when base class is not abstract

I need to map a model to a derived class based on a condition, but otherwise map to another class. for example if I have these classes class Shape { } class Rectangle : BasePolygon { } class Square :...
Moniker's user avatar
  • 135
0 votes
1 answer
46 views

DRY - Derived class with static methods

In Unity C#, I have a base class Baker, it's derived from ScriptableObject, and I'm deriving from it CakeBaker, BreadBaker, PieBaker. ScriptableObjects can only be created statically, using ...
TheUmpteenth's user avatar
-2 votes
1 answer
58 views

Cast a List<derivedType> into a List<baseType> without breaking the reference

I have multiple lists of type ArmorBase and WeaponBase that inherit the ItemBase class. I also have a List that represents the current selected item List public List<ItemBase> ...
Bruno Pasini Fiorini's user avatar
-1 votes
1 answer
66 views

Hide fields in child class when inheriting

Is it really impossible to hide these two fields in the inspector of the child class when inheriting, without using a custom inspector? If yes, then what is the best way to change the value of ...
Ilya's user avatar
  • 374
0 votes
1 answer
62 views

C# Generic with both notnull and nullable fields

I need a class for a regular tree in the whole project. Sometimes the tree is used with a string key and sometimes with a Guid key. This class should have not null Id and nullable ParentId. If i use ...
Vitaliy Kuznetsov's user avatar
-1 votes
2 answers
93 views

Inherit interface and automatically implement the properties

I have a case where I should inherit a class from an interface that will automatically implement without typing the implementation inside the parent class, is it possible? For example: public ...
Topik's user avatar
  • 41
-3 votes
2 answers
110 views

Does anyone know why I am receiving the error: Cannot implicitly convert type 'void' to 'string'? [closed]

I know the problem has something to do with the nested WinOrlose() method within the PlayGame() method, however not sure where to go from here. Random random = new Random(); // ... (irrelevant code ...
Nathan Shetzler's user avatar
-1 votes
1 answer
41 views

How to set up classes for parsing custom data types in C#

I'm working on a saving/loading system, and I'm trying to serialize and deserialize various objects. I'm working in Unity, and I've created one custom class for the game objects and their behaviours, ...
Adam L.'s user avatar
  • 89

15 30 50 per page
1
2 3 4 5
440