Categories > Coding > C# >

Welp me optimize terrible code


New Reply

ishanjit321

Ishan

Posts: 167

Threads: 38

Joined: Mar, 2022

Reputation: -6

  • 0

Posted

https://cdn.discordapp.com/attachments/986313395882037258/988504638066147389/unknown.png

how optimize

RealNickk

am h3x0r

patron Mention

Posts: 3053

Threads: 147

Joined: Feb, 2020

Reputation: 35

  • 0

Replied

That simply cannot be optimized.

Your code is very ugly and bad.

4b5951d5-1b9b-407b-b514-78eb46591564

Aja

Zenexya#2964

Mention

Posts: 1079

Threads: 121

Joined: Apr, 2021

Reputation: -1

  • 0

Replied

Can't you just add

using Microsoft.Win32;

 

And then do the OpenFileDialog without the shortcut?

That kinda makes the code bad.

Posts: 167

Threads: 38

Joined: Mar, 2022

Reputation: -6

  • 0

Replied

 HOLY THAT REDUCED RAM USAGE BY 40% 

THANKS @Aja

ImmuneLion318

Nihon Owner

moderator Mention

Posts: 1110

Threads: 65

Joined: Oct, 2019

Reputation: 66

  • 0

Replied

var FileOpen = new OpenFileDialog()
{
      Filter = "*Txt (*txt)|*.txt|Lua (*lua)|*.lua",
      /* Do Other Properties Like Starting Dir And Stuff */
};
Editor.Text = File.ReadAllText(FileOpen.FileName);

 

Posts: 227

Threads: 10

Joined: Feb, 2021

Reputation: 9

  • 0

Replied

Uh so if you use avalonedit it has built in load function which u can use.

Sorry if im wrong, i havent touch wpf/c# in ages lol + i write this without ide

Also make sure you using the win32 one

var FileDialog = new OpenFileDialog()
{
    Title = "Open File",
    Filter = "*Txt (*txt)|*.txt|Lua (*lua)|*.lua"
};

if (FileDialog.ShowDialog().GetValueOrDefault())
    Editor.Load(FileDialog.FileName);

Im netral, not evil, not too kind either.

tar

CoolNickname

Mention

Posts: 107

Threads: 10

Joined: Jul, 2021

Reputation: 1

  • 0

Replied

Just dont create a OpenFileDialog everytime, create once and reuse it

and " == true"💀

https://imgur.com/a/oOomuUo


New Reply

Users viewing this thread:


( Members: 0, Guests: 1, Total: 1 )