Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
-1 votes
1 answer
48 views

In my C# project I get an string [,] type object as an output. When I want to print the output to console or file, the output is truncated. Why?

I have the method below, where I am subscribing to an OPC DA server items. public void read_OPC_items(string ip) { using (var client = new EasyDAClient()) { client.ItemChanged += ...
Mdarende's user avatar
  • 661
1 vote
3 answers
70 views

Unable to cast to object

I had a code: var result = BOBase.Search(Mapper.SourceBrowserType, searchCriteria); var list = new List<IBO>(result.OfType<IBO>()); But I need to be able to add many elements in a list. I ...
vytaute's user avatar
  • 1,440
0 votes
2 answers
515 views

Convert List<object> to List<model> type with only the model name c# mvc

So I'm trying to create a generic function (currently it's not but I wanted to future proof it, so in a later stage the tableName can be picked/passed through). I want to use the string ...
Manib's user avatar
  • 181
1 vote
0 answers
105 views

How to cast object to Anonymous T

I'm having a problem casting with C# First, my auxiliary functions for better understanding public static class Extensions { public static IEnumerable<T> ToEnumerable<T>(this T value) {...
Uğur Demirel's user avatar
0 votes
2 answers
83 views

Will updating type casted object update the non-type-casted object [duplicate]

I have an array of objects, and I want to use a setter function to update one of them. However, the array's type is of the parent class, which doesn't have the setter function. So I type casted the ...
root's user avatar
  • 3
-2 votes
1 answer
365 views

C# Generic way to store unknown properties in List

I'd like to store LicenseInformations for multiple domains in my application. The structure looks the following way: public class LicenseData { // properties... public List<...
Andréw's user avatar
  • 106
2 votes
1 answer
250 views

Cast Dictionary<int, Object1> to Dictionary<int, Object2>

I have these 2 objects, a dictionary, and a method public abstract class Thing {} public class Star : Thing {} Dictionary<int, Star> dictStar; public void listBoxAdd (Listbox listBox, ...
Peter's user avatar
  • 93
0 votes
1 answer
108 views

Convert object(int[,]} to int[,]

I'm trying to write simple program to get image from astronomy camera, image data is read as object{int[,]} according to this doc: ASCOM.DriverAccess.Camera.ImageArray To display and convert this ...
KorneliuszM's user avatar
-2 votes
3 answers
108 views

Convert an Object (not defined) to an Object with a Type

I have this code: object temp; if (choice == 1) { temp = new HardCopy(); Books = p.AddBook(temp, Books); } else { //EBook temp = new EBook(); //Books = p.AddBook(temp, Books); } ...
Ethirix's user avatar
  • 13
-1 votes
1 answer
227 views

C# Object Property to Load Values from List

I have a class with a property: public object something { get; set; } I obtain a list of values from a method, say List<string> myList and I would like to load each value into property ...
Nick's user avatar
  • 513
3 votes
3 answers
2k views

How do I cast an object to another object type with all the same properties except the new type has one more field

I am trying to cast the type skill to type SkillViewModel. This is where I try the cast: SkillViewModel skillViewModel = (SkillViewModel)skill; This is my skill model that I am trying to ...
jenkamin-benbins's user avatar
0 votes
1 answer
557 views

C# Converting an anonymous object with nested collection into an IEnumerable - preferably using the 'as' keyword

My code receives an anonymous object created by another method. I would like to access and iterate through the nested collection in this object. I was trying to come up with several different ways to ...
mrkozma's user avatar
1 vote
1 answer
49 views

Calling a ClassA.Method() as ClassB.Method() but only affecting ClassA values, both classes are deriving from the same BaseClass

In this example I am building an automation library for browsers. There is a base class called Mouse, and derived classes called RoboticMouse and HumanMouse. Lets say I instantiate the mouse as ...
Joao Vitor's user avatar
1 vote
1 answer
61 views

Is using an "object" property a proper thing to do?

I have to get back an object the frontend is sending me. Thing is, front team wanted their component to be as generic as it can be so, in the dto, i'll recieve a Value property that can be different ...
j0w's user avatar
  • 545
0 votes
1 answer
33 views

Better way to check if Object is of some Type bevor using it as said Type?

I have a huge if else statement where an Object is getting check for a specific type bevor it is used in a method. Is there a shorter/more effective way of doing this? A bit simplified my code looks ...
Painkiller's user avatar

15 30 50 per page
1
2 3 4 5
7