C
C#fateos

❔ HeadFirst Design Pattern

So I started with this Book today. First problem starts with the Duck Project: and when he tests he makes an instance of an abstract class ???? Is this a Java thing that works but not in C#?
T
TheRanger387d ago
he did not make an instance of an abstract class
F
fateos387d ago
Duck mallard = new MallardDuckk
T
TheRanger387d ago
Duck is an abstract class MallardDuckk isnt
F
fateos387d ago
but how can you say Duck mallard = ?
T
TheRanger387d ago
he's making an instance of MallardDuckk, not Duck its upcasted
F
fateos387d ago
so you can make a variable of Duck but not with the new operator
T
TheRanger387d ago
yes
P
Pobiega387d ago
variable can be Duck, the instance can't. abstract just means "you cant create instances of this type"
F
fateos387d ago
oh okey so my problem is different
F
fateos387d ago
F
fateos387d ago
this is in my program.cs
T
TheRanger387d ago
what does the error message say
P
Pobiega387d ago
That should be fine, assuming your namespaces and stuff are correct.
F
fateos387d ago
F
fateos387d ago
is it because my class has the same name as my project?
T
TheRanger387d ago
dont name ur namespace and class the same name
P
Pobiega387d ago
Your type shares a name with the namespace. yes
F
fateos387d ago
so I have to find a way to refactor all namespaces in my project
P
Pobiega387d ago
thats fairly easy, just use the built-in renaming tool. Ctrl+R, R by default. set your cursor (the writing marker) on the namespace and do the shortcut
F
fateos387d ago
oh thats coolk thank you so does this replace everyything in my solution or project? and is it casesensitiv and matches the exact word?
P
Pobiega387d ago
namespaces are case sensitive
F
fateos387d ago
because I was using CTRL + H all this time yes I know but the CTRL+R,R I mean
P
Pobiega387d ago
so, thats your normal text-based search and replace the rename tool follows code references
F
fateos387d ago
for example I wanna replace foot but have other variable called football would CTRL + R, R also change the foot in football?
P
Pobiega387d ago
no its not doing it by text its doing it by the code identifier
F
fateos387d ago
by code identifier u mean if I change namespace it only looks for other namespaces and not variables or anything else
P
Pobiega387d ago
yeah, its context aware if you are changing a namespace, it only changes namespaces. but it changes them everywhere they are used, including in fully qualified type names etc
F
fateos387d ago
so for variables I shouldnt use CTRL+R,R
P
Pobiega387d ago
yes you should its context aware. it knows what it is changing its NOT a string based search and replace.
F
fateos387d ago
hmm ok so when would u use CTRL + H ?
P
Pobiega387d ago
never, for changing code search and replace is dangerous, as "foot" and "football" shows
F
fateos387d ago
ye I didnt know about CTRL+R,R so I would always go with CTRL+H and go each change one step at a time to make sure everything gets renamed correctly thankk you all I just had to put using DuckProgram; and now it works
P
Pobiega387d ago
you can set a "default namespace" in your project properties too so a new file wont get Duck by default
F
fateos387d ago
well its my fault I need a Duck class but I can call my project whatever
P
Pobiega387d ago
you could just rename the Duck class 🙂 DuckBase or something
F
fateos387d ago
it wouldnt make sense to change the Duck class it makes more sense to rename the Project
P
Pobiega387d ago
sure, but more work 🙂
F
fateos387d ago
how? CTRL R, R did it perfectly
P
Pobiega387d ago
¯\_(ツ)_/¯
F
fateos387d ago
🙂
A
Accord386d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
✅ EqualityComparerHello, anyone know of this code work ? --> `EqualityComparer<ICollection<myclass>> .Default.Equals❔ error attaching script (unity)this error appears when trying to attach the script, does anyone know how to solve it?❔ i have an app that runs well on my pc but not on other pcsi have an app that runs well on my pc but on when i zip it and bring it to another pc the ui is all yield???```cs public IEnumerable<int> A() { for (int i = 0; i <= 10; i += 2) yield return i; } C# Data Table issuehttps://pastebin.com/DSHwSh0M based on this program, I need to set the values of the `Old PS A11Y S❔ Microsoft Graph SDK - Serializing objectsHello, I am currently working with Microsoft Graph API to work with the Planner. My goal is to backu❔ XML deserialise different types into a single listI'm using the build in XML serialisation library (unless it's with .NET framework?), and I current h❔ Access things from different scene in UnityI have a Class Selector scene that has a Class Selector Script component (MonoBehaviour) attached to❔ C# how do I write an If-statement to handle a button?Hi, I wanted some assistance with writing a If-statement that filters out the zones section in my ap❔ Magnetic Links for application?Hey, does someone have an article/tutorial/explanation how I can develop magnetic links for my appli❔ Show values from a list in a datagridview getting source from bindingsourceHello! I have the following problem: I am currently developing a winforms app with a datagridview th❔ Render email content .NET 7 (razor)I have to reinplement email content rendering, because currently its not looking really good, especi❔ GetAxis wont workpublic class Driver : MonoBehaviour { // Start is called before the first frame update const✅ (SOLVED)Help a Beginneri am following CodeMonkeys 11Hr youtube video on coding a game in unity. I have ran into a issue whe❔ Exclude items from linq query if they contain one from an array of substringsI've got a list of strings, that if they appear anywhere in a linq query column i want to exclude th✅ Comprehension questions (LeetCode Binary Search)Like the title says it's about this puzzle https://leetcode.com/problems/binary-search/description/ ❔ How to create a cubic function calculator that also calculates the minimum and maximum value```c Console.WriteLine("Please enter a, b, c, d for the cubic function ax^3+bx^2+cx+d"); ❔ how to listen to the output of a virtual audio device on windows using C#?how to listen to the output of a virtual audio device on windows using C# to save the raw audio stre❔ How to wait for process to completei want to make program opens async but instead of giving 'hard coded' delays but i don't know how to❔ Problem with including C DLL in a C# console app project.So I have this C DLL imported into my console app (.NET 5). I simply cannot get to call it correctly