Is it correct to emulate basics features
See original GitHub issueIn the C# implementation for the Calendar program, the author emulated the basic function TAB
, but if I understood it correctly, this repository should build up a reference for learning the various langauges and therefor emulate the behaviour of the original program. While using the native features of the language.
So I think this should be replaced with a simple call to just new string(' ', n)
.
And if one would want to show how can build up a string incrementally, then the implementation should be
var strBuilder = new StringBuilder(n);
for (int i = 0; i < n; i++)
{
strBuilder.Append(' ');
}
because using +
on string
s in a loop is an anti-pattern which no one should learn.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Simulator or Emulator? What is the difference?
In short: an emulator is designed to copy some features of the orginial and can even replace it in the real environment. A...
Read more >What is emulation? | Definition from TechTarget
Emulation, in a software context, is the use of an application program or device to imitate the behavior of another program or device....
Read more >Emulator - Wikipedia
Emulation refers to the ability of a computer program in an electronic device to emulate (or imitate) another program or device. DOSBox emulates...
Read more >The Pros and Cons of Playing Video Games on an Emulator
Emulating video games has several benefits, but it's not perfect. Let's look at the pros and cons of game emulation.
Read more >What Quality of Life features should more emulators ...
Dolphin actually has both, though the first feature is not very easy to find. You have to right click on the input config...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The tab© moves to the next column c, independent of the length of previous thing that was printed. This is actually a useful thing, and not equivalent to: “new string(’ ', n)”.
I’ve been wanting to dive into this tab(x) thing. Here is what I found:
Other languages can’t do this with a simple function because it does not know the current position on the line. Languages that I know do this with a format string to pad items with spaces, so the next thing starts at the same column as the line above it. This is Python, and almost identical to Rust using index numbers to choose the values and alignment > and the padding:
Similar in C# Console.WriteLine(“{0,10}{1,10}{2,10}”, x, y, z);
Oh cool, C# let’s you embed the variables in the {} braces instead of indexes. Start the format string with a $" --You’d be a coding hero if you showed how to do that!
Also, I wonder if the tab character works? print(x+“\t”+y+“\t”+z) david.
You can actually do this in c#. At the class
Console
we have properties and methods that allow us (on the supported OSs) to read and set the cursor position.I’m also now unsure how many spaces the basic code would produce for the
PRINT TAB(32);"CALENDAR"
I would also assume that the purpose of the tabing is to center the text in the console window. So one could argue that we should determin the width of the console with
Console.BufferWidth
and do a proper centering based on this width.Regarding the tabbing, in gerneral I see 4 ways to do it that would be common and easy to unterstand