KKSK@🌸🎵🌸🎵🌸
KKSK@🌸🎵🌸🎵🌸
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
I guess the only solution is an AutoMapper?
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
I just called it a shared library because both project is referencing it
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Is actually not shared project as the one in VS is just a library created in net framework. And I referenced it
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Net framework is the shared project target
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
And manually parsing
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Originally everything was all tcp socket
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
The class was originally in the Net 6 project where the methods include some libraries that may not be compatible in the net framework class. I am currently implementing a shared library that uses an interface based grpc to communicate in between. So I am trying to move the class to the shared project.
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Mainly because I want to separate this class so that I can pass the properties class instance to the method from the net framework project and call methods only in the Net 6 project.
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
I just kind of understand your comment. What you mean is if object was child and was cast to parent, this can be cast to child again? But my case was the original is of a parent, and I am passing this parent object to this method. Within the method I am casting it to child. So it seems like impossible?
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Can I rewrite the above to the following?
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
And UnitAbnormalStateChangeData have the rest of the original methods
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
Where UnitAbnormalStateChangeData inherits UnitAbnormalStateChangeDataProperties
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
So if I break this class into
27 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 2/5/2023 in #help
❔ cast parent to child
27 replies
CC#
Created by V0FBU1VM on 12/10/2022 in #help
❔ Write an Aggregate
Yes, you could use the Aggregate method to achieve the same result as the code you posted. The Aggregate method allows you to perform a calculation on a sequence and return a single result. In this case, you could use it to track the visited houses and return the total number of houses visited. Here's an example of how you could use Aggregate to accomplish this:
public override string SolvePartOne()
{
// Initialize the set of visited houses with the starting house at (0, 0)
var visited = new HashSet<House>()
{
new House(0, 0)
};

// Use Aggregate to track the visited houses
visited = Input.Aggregate(visited, (houses, direction) =>
{
// Update the current position based on the direction
switch (direction)
{
case '^': y++; break;
case 'v': y--; break;
case '>': x++; break;
case '<': x--; break;
default:
throw new InvalidDataException();
}

// Add the new position to the set of visited houses
houses.Add(new House(x, y));

// Return the updated set of visited houses
return houses;
});

// Return the total number of visited houses
return visited.Count.ToString();
}
public override string SolvePartOne()
{
// Initialize the set of visited houses with the starting house at (0, 0)
var visited = new HashSet<House>()
{
new House(0, 0)
};

// Use Aggregate to track the visited houses
visited = Input.Aggregate(visited, (houses, direction) =>
{
// Update the current position based on the direction
switch (direction)
{
case '^': y++; break;
case 'v': y--; break;
case '>': x++; break;
case '<': x--; break;
default:
throw new InvalidDataException();
}

// Add the new position to the set of visited houses
houses.Add(new House(x, y));

// Return the updated set of visited houses
return houses;
});

// Return the total number of visited houses
return visited.Count.ToString();
}
As you can see, the Aggregate method allows us to perform the same operations as the code you posted, but with a more concise and functional-style syntax. I hope this helps! Let me know if you have any other questions.
7 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 12/10/2022 in #help
❔ Convert unicode characters in json value to Japanese or Chinese or Korean characters.
24 replies
CC#
Created by KKSK@🌸🎵🌸🎵🌸 on 12/10/2022 in #help
❔ Convert unicode characters in json value to Japanese or Chinese or Korean characters.
System.Text.RegularExpressions.Regex.Unescape(text)
System.Text.RegularExpressions.Regex.Unescape(text)
This is the real solution
24 replies