instruction
stringlengths
71
71.9k
I currently have a code that is connecting to SQL database in VBA. The data is populating correctly. However, I was wondering if there is a way to condense the code below. I have 4 different columns and 26 rows and I feel like if I go this route, I will be wasting a lot of time. I want the range to go from C20:C45 and...
How can I improve this component with using event delegation rather than doing a lookup using parentNode so that I can change the markup around without having to update the JavaScript? HTML <div class="drop-down-wrapper"> <div class="drop-down-btn-wrapper"> <div class="drop-down-open"><img src="http://plac...
What is the fastest Pythonic way to remove all stopwords from a list of words in a document? Right now I am using a list comprehension that contains a for loop. from nltk.corpus import stopwords ''' Push stopwords to a list ''' stop = stopwords.words('english') Document = ' Some huge text .......................... ' ...
I'm implementing a lock-free, multiple consumer, multiple producer FIFO queue/pipe as an exercise in thinking about atomicity in operations. My main concern is correctness of operation, my second concern is good practices around atomics and general C++11. Performance is interesting but not important for this exercise. ...
I have a Polygon array, and I need to get a Rectangle object which bounds all of the polygons inside the array. Think convex hull - except this is a rectangle and not a polygon. Here's my current code which works: public static Rectangle getBoundingBox(final Polygon[] polygons) { if (polygons == null) { ret...
I have a rails application that uses Stripe for credit card processing. Currently several exceptions are being handled anywhere a transaction takes place. The code below is being used currently in 11 places. In all places it is essentially the same with the exception of the message being passed to stripe_error. Is it p...
This post is somewhat of a follow-up to Rubberduck's "Extract Method" refactoring implementation. A tremendous amount of things have changed since version 1.2, when this feature was first introduced - the more important thing being the advent of the Declarations API, which implies that the feature now not only gets an ...
Right now I am using a regex to extract emails from a text document, and filter the duplicates out of this using the Distinct function from linq. After which I run the output file through a clean up of duplicates as well, as the program can be run several times over several different files. Now my question, would ther...
I have an excel file with 20+ separate sheets containing tables of data. My script iterates through each sheet, manipulates the data into the format I want it and then saves it to a final output file. I think it can be improved, and I've flagged sections in the code with "review this" which I think I've done more work ...
I asked a question elsewhere on Stack Exchange and was given an answer by multiple people that checking for errors in-line was not a good practice. I have been using an on error resume next ' do something on error goto 0 block structure for years as kind of an improvised try-catch construct for VBA. Here is a simpl...
I started writing unit tests cases recently. For now, I created only "perfect case" where there is no error. However, the test seems to me difficult to maintain and difficult to understand. How can I make it better for other people to understand? All permalink attributes are set within the service itself I'm testing (P...
I have a validation which checks that a string is a valid asset number. There are currently three formats it could be in, like: 001-123456, WSH002M52B, or CTR0025MLD. The way my code is set up now is like: public bool IsValidAssetNum(string assetNum) { if (this.IsNorthAmericanAssetFormat(assetNum)) return true; ...
My question is whether or not this is a good practice, and/or if there is a more efficient way to do it. I have to access this Solidworks interop object and wait for it to return some value. The return is a string. In early testing I found I ran into issues if I didn't wait for the return, so I added a "DoEvents" wa...
Below you will find my first attempt at a C++ implementation of the classic game Rock-paper-scissors. If someone could look it over and point out or suggest any things that I could change to improve it, that would be brilliant and I would greatly appreciate it. Player.h #ifndef PLAYER_H #define PLAYER_H #include <iostr...
package com.raja.util; import java.util.Arrays; import java.util.HashSet; import java.util.Random; import java.util.Set; public class Hashtable { private Object[] slots; private int capacity; Hashtable(int size) { capacity = size; slots = new String[size]; Arrays.fill(slots, "-1")...
I am working on a version of std::unique_ptr and std::make_unique for aligned memory. The purpose of this is vectorization, e.g., SSE or AVX, which has higher alignment requirements than the underlying types. My header providing aligned::unique_ptr and aligned::make_unique (compiles with C++11, no need for C++14 suppor...
I thought of a program where you move a square with the arrow keys. I created it and asked a question about it on Stack Overflow. I copied the last code block of the accepted answer and tried to understand it. I think I do now. Now I wanted to add something that would check if the square would move off the screen. I ad...
I was compelled to look into a Sudoku Solver in Java using the principles I have learned in a course, namely I wanted to make something that included backtracking and forward checking. Has anybody else managed to produce a Sudoku solver that uses the forward checking algorithm that is more efficient than the backtracki...
I implemented this code, looking at a dependency injection program as an example. I wanted to confirm with you all whether this implementation is the right way of doing the same. namespace TestAsyncProjectWithDI { public interface IReadFileTypes { void ReadUsingFileSteamA...
This is a fun one! I wrote some code to automatically get the next revision letter for a file by looking at the existing letter. It works, but I think there is room for improvement as far as simplifying it or making more efficient. Our revision scheme follows ASME Y14.35, which specifies the following rules: First ...
I developed three methods that have only some similarities, and the three must remain separate. However, it seems there is a significant amount of duplicate code. They basically seek the same list and set a BasicDBObject with a few different attributes. How can I solve it? Or is acceptable as is? These stretches of dup...
I am trying to complete a Ruby coding exercise. The specifics of the excercise can be found on a the level_up_exercises GitHub repo. This repo also contains the CSV file used in the exercise. I would like you to comment on how well you think I met the requirements with the exception of loading the African dinosaur da...
As MATLAB has a hard maximum of 10 input arguments it's possible, but ugly, to implement a curry function in this manner: %% turns a standard function into a curried one % if g has 3 input arguments then you can call: % h = curry(g) % h(1)(2)(3) == g(1, 2, 3) % Matlab doesn't like h(1)(2)(3), but in principle it wo...
I wrote a shell to test my understanding of processes etc. It is not supposed to comply with POSIX or anything, just to allow people to run simple commands with simple arguments. #include <stdio.h> /* printf, fprintf */ #include <stdlib.h> /* exit */ #include <string.h> /* strtok */ #include <unistd.h> /* fork, execvp...
I have a large application with a wide-reaching amount of views and sub-views. I have a need to decorate DOM elements with identifiers so that my framework of choice can bind views to the DOM elements. In attempting to choose a robust convention for naming these selectors, I've encountered a few problems: id selectors...
The input begins with the number \$t\$ of test cases in a single line (\$t \le 10\$). In each of the next t lines there are two or more numbers \$m\$ and \$n\$ (\$1 \le m \le n \le 1000000000\$, \$n-m \le 100000\$) separated by a space. Print each number in a separate line which can be used further for summatio...
I am very new to this and am using php and MySQLi to create a form which will create a record in a third table. This works fine but I can't help but think that there is a way to do it with a single query rather than a query for each table as I have now. The third table is called tblcars, and I will use this form to b...
Rubberduck code inspections can take quite a while to complete, so I decided to run them on a background thread instead of locking up the IDE. The only drawback is... the IDE isn't locked-up while inspections are running, so the user can end up with inspection results that go against stale parse results - this could me...
This is my first time writing ruby - and I was mainly hoping to get some feedback and stylistic pointers. The algorithm is pretty straight-forward, since Google guarantees airports aren't repeated I store all the tickets in a hash table and then sort from random insertion points, which should be worst case \$O(n \log ...
This is the To and Fro problem at SPOJ: Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is “Ther...
I have some code here that I am very unhappy with. The task I am trying to accomplish is this. Given a 2d vec like this: [[0 2 0] [1 3 5] [3 3 0]] which can contain positive ints including zero I want to remove all lines that are greater zero. Where the definition of line is the following: A line is represented by th...
I'm going through some of the problems over on exercism and we were asked to write a program that finds the nth prime. I know Ruby has a Prime class that handles that but the exercise doesn't allow us to use that. My code works fine but it's very, VERY slow when testing very large numbers (e.g.: the 10,001st prime num...
I have constructed a copy constructor for an ADT queue. The copy constructor works fine. I would want to improve my code, but I don't really know how to shorten it to make it more flexible. template <typename T> Queue <T>::Queue(const Queue & other) { if (other.first == nullptr) { first = nullptr; ...
This is my very simple client-server application. Client sends some commands to the server and server gives back the output to the client. However, my special concern is about the GET command sent to the server. The client request GET filename to download a named file. That file ultimately gets downloaded into the clie...
Right now I have a list of dictionaries. In order to filter out all the entries I do not want included in the list, I am running it through multiple list comprehensions. Is there a more Pythonic or better way to write these comprehensions that seem repetitive? #FILTER OUT ALL EMPLOYEES WHO WILL NOT BE FACTORED INTO MET...
This is how I can access the exact scope value, otherwise it will be $scope.type of local scope. I am accessing this from the template in NSPopover. NSPopover directive has scope: true. It's also inside the Angular bootstrap module. <label ng-class="{selected: $parent.$parent.$parent.type == current.type}" > <input...
I'm building a news aggregator website. This is my current schema structure for a single news article. There can be more than one article per page. I'm trying to have every possible piece of data structured. Am I missing something? How can this structure be schema.org-optimized for a news article post? <article itemsco...
I am trying to practice objects and functions (specifically closures & higher order functions) in javascript. There is no specific reason why I chose this program but it struck my mind to work out this one. The below code is available at my Github and it converts the number to words. Kindly provide your feedback and s...
Scenario "The Semantic Mind-Reader!" browser known as jhool is known as mind-reader for a reason. Here's why: You don't need to type 'www.' to open a website anymore. Though, you still need to type '.com' to open a website. The browser predicts ALL THE VOWELS in the name of the website. (Not '.com', though. Agai...
procedure E(n, m: integer; A, B: tMatrix; var C: tMatrix); var i, j: integer; begin for i:=1 to n do for j:=1 to m do begin if i<=j then C[i,j]:=A[i,j] + B[i,j] else C[i,j]:=A[i,j] - B[i,j]; end; end; Input: three matrix. Output: new matrix which created by addition or subtraction of two el...
To start, I am in the wrong language and I think it is time learn some C++ and compile it as an add-on for NodeJS. For now, though, I have a few code snippets that work that may be interesting or may be an abomination of coding. This code works with weather forecast data, specifically the GRIB-2 file format. GRIB-2 com...
As I was looking through my past questions, I noticed my really old calculator question (here and here). Considering it looked like a huge mess, I decided to rewrite it. Coincidentally, the April 2015 Community Challenge was to implement a simple calculator. It might be a bit late, but here it is: import java.util.Hash...
Today I started to build my first platformer, first time working with collisions and stuff. Now, surprisingly, everything seems to work, but since this is my first time creating a platformer and I'm still a beginner with collisions I don't know if the way I coded it is good practise. The game is a ball with a fixed x c...
I have two arrays that I need to compare if their IDs are equal. This is how I am currently doing it: PFQuery *earnedQuery = [PFQuery queryWithClassName:@"EarnedAchievement"]; [earnedQuery whereKey:@"user" equalTo:[PFUser currentUser]]; [earnedQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {...
The code I have below swaps two tabs around. This is done through creating an array, deleting all tabs and then recreating them which seems very inefficient to me. Private Sub SwapTabs(ByVal tabOne As Tab, ByVal tabTwo As Tab) 'get array of all tabs Dim tabs() As Tab = Me.Children.OfType(Of Tab).ToArray 's...
I want this code to be reviewed, please. chatServer.java import java.net.*; import java.util.*; import java.io.*; class chatServer { static Vector<Socket> ClientSockets; static Vector<String> LoginNames; chatServer() throws Exception { ServerSocket soc = new ServerS...
I challenged myself to implement multiplication of signed integers using only +, -, >>, <<, &, |, ^, and conditionals, though I would like to improve my method to not use conditionals if possible in the future. Any input would be very helpful. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <limits...
A library that I use doesn't support SecureString in its credentials for connecting to GitHub, so I'm submitting a pull request to add it. I know it's not ideal to pull the actual string out, but the idea here is to minimize the amount of time the string is in memory. Also, allowing client code to utilize the fact that...
I've reproduced the jQuery selector function in JavaScript. Here are the two rules that come with this function: You may not use any JavaScript libraries. document.querySelector/document.querySelectorAll may not be used. var $ = function (selector) { var elements = []; // get starting index position of id / clas...
I am writing the lemonade stand game in Java but I am having a bit of trouble trying to figure out the perfect recipe. I have most of the code done, except the math logic seems a little off. Please let me know if I can improve the code. public static void main(String[] args) { ///declaration of variables i...
I'm currently attempting to learn some basic JVM optimization techniques using JMH. I created the following bench to compare mid-index insertion performance between ArrayList and LinkedList. How exactly do I measure score vs error in the final results? The documentation states: Your benchmarks should be peer-re...
Q1. Define a function reverse_list that takes a list as an argument and returns None, but reverses the elements in the list as a side effect. Do not use any built-in list methods (especially not reverse), but assignment statements are fine. Below is the iterative solution: def reverse_list_iter(s): """Rever...
Q2. Define a function make_accumulator that returns an accumulator function, which takes one numerical argument and returns the sum of all arguments ever passed to accumulator. Use a list and not a nonlocal statement. Below is the solution: def make_accumulator(): """Return an accumulator function that take...
Q4. Define a function make_counter that returns a counter function, which takes an immutable key and a numerical value argument and returns the sum of all arguments ever passed to counter with that same key. Below is the solution: def make_counter(): """Return a counter function. >>> c = make_counter()...
I wrote a simply parser for Tektronix's internal binary file format .isf. The code is supposed to read in the file and return the header data as well as the actual oszi-data. Since I mostly code by myself, I would like your opinion on whether my code follows common practice and whether it can be improved. import numpy ...
I'm working on a linear algebra module to improve my knowledge with mathematics and, because I'll need a lightweight linear algebra module for my future work with Vulkan! I tried to keep a blas-like routine style, for exemple, the related functions are called like this: template <typename T, std::size_t M, std::size_t ...
The code snippet below examines a nuget package file (zip file with meta) and extracts all file names referenced inside. The final result should be a Set<string> with all file names. My problem is that the code looks like a nested Linq query in c# and the usage of Seq.iter blocks me to build the Set collection. Can you...
The doctest module seemed easy to implement so I decided to write a simpler version of it. my_doctest.py def _doublets(lst): for index, item in enumerate(lst[:-1]): yield item, lst[index+1] def _test(tests): for prev, curr in _doublets(tests.splitlines()): if prev.strip().startswith('>>>'): ...
I was trying to calculate the factorial of a large number in a short time: class TestClass { public static void main(String args[] ) throws Exception { BufferedReader keyboard=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(keyboard.readLine()); while(n!=0){ ...
As pyglet has no in-built method to return a vertex list of circle, I had to build one myself. This is a critical piece of code that I will use very frequently. I need it to be of very fine performance. Here's what I've written: """ Pyglet utilities. Designed to ease drawing of primitives with Pyglet. """ # Dependenci...
This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three datacenters in production: DHP, SLP, LTR Depending on which datacenter code is running, I need to make a LinkedList (allPaths)...
I've am trying to read a large text file and output the distinct words in it along with it's count. I've tried a couple of attempts so far, and this is by far the fastest solution I have come up with. private static readonly char[] separators = { ' ' }; public IDictionary<string, int> Parse(string path) { var word...
I am new tro programming and have chosen python 2.7 to begin with. But, I often have to deal with a TLE while competitive coding like in the problem below, where my code runs fine on all test cases but runs out of the given time bound. My code runs fine on Ideone.com for all the given test cases, but gives a TLE on SPO...
I'm trying to solve this fairly straight forward challenge: Problem Statement In computer science, a set is an abstract data type that can store certain values, without any particular order, and no repeated values. {1,2,3} is an example of a set, but {1,2,2} is not a set. Today you will learn how to use sets in ...
I want to check as fast as possible if an entity, based on PartitionKey and RowKey, exists in an Azure Table Storage. I can do a standard TableOperation.Retrieve and check the result, like: TableOperation retrieveOperation = TableOperation.Retrieve<CustomerEntity>("Smith", "Ben"); TableResult retrievedResult = table.Ex...
Yesterday and today I've made a very basic syntax highlight. It creates a function in the window object that handles part of the job: (function(window){ var f=window.highlight = function(lang, element){ var lang_defs = f[lang]; if(!lang_defs) { throw new TypeError( 'The langua...
I have a Location type: public abstract class Location implements Locatable { private int x, y; protected final void setX(int x) { this.x = x; } protected final void setY(int y) { this.y = y; } public final int getX() { return x; } public final int getY() { ...
For practice, I tried implementing Bubble sort in Ruby. I wasn't very sure how nested for loops would look like in Ruby. Is this the 'right way' to do this in Ruby? I found this question, but it looks much more complicated with stacks. def bubble_sort(list) n = list.length n.downto(2) do |i| 0.upto(i-2) do |j| ...
I've completely revamped my old syntax highlighter, and made it more flexible and easy to use. It works the same way as the previous one, wrapping <span> elements around sections of text in an element with certain styles, but it now allows for string highlighting, and is more extensible by allowing the user to define t...
I recently came across the classic algorithm for detecting cycles in a directed graph using recursive DFS. This implementation makes use of a stack to track nodes currently being visited and an extra set of nodes which have already been explored. The second set is not strictly required, but it is an optimization to pre...
I have a Spring @Service to asynchronously send emails. The part that seems to be a bit off to me is some code that is specific to our QA environment. We want to send and receive all emails through a test email account so that it does not impact live users if we work with real data imported to QA. I check for the en...
I wanted to write some more JNI code and decided to (re)implement a semaphore for MacOSX. In order to assert somehow correctness of my implementation I hereby supply a (multi)consumer/(multi)producer demo. semaphore_impl.h (autogenerated by javah): #include <jni.h> #ifndef MACOSX_SEMAPHORE_IMPL_H #define MACOSX_SEMAP...
I'm making a Chrome extension that lets you choose a size of an item and check out quickly. I have a value called "Large" in sizePref array in my chrome.storage. And when it calls that value, it will choose an option in a dropdown based on that. However, possible labels are "Large", "L", "M/L" or "L/XL" ("Large" being ...
I have N child classes of the same base class. The base contains abstract methods to convert the class to a byte array and vice versa. It also contains a method to compare that instance to two other instances of the same type. Result shall be true if this instance is within the range of the other two instances (each pr...
I wrote a utility class that is used to extract the contents of a ZIP file to a destination folder. This is a very small class, but it has several practical applications: it can not only be used to extract a ZIP file, it can also be used to extract JAR and EPUB files. UnZipper.java package reader.utils; import java.io...
I am trying to learn BDD in PHP with Behat and Mink and I am using Selenium2 driver for the same. The scenario is given on this page and is as follows: Feature: Search In order to see a word definition As a website user I need to be able to search for a word Scenario: Searching for a page that does e...
A while ago I had the idea to store all the important configuration and dotfiles from my system in a Git repository. That saved me a few months ago: My harddrive died, but I could get back to work with Ubuntu and that repository quickly. Only problem: I maintained that repo by manually copying the files from the variou...
I have finished Project Euler #9 on HackerRank: Given \$N\$, Check if there exists any Pythagorean triplet for which \$a+b+c=N\$, \$a^2+b^2=c^2\$. Find maximum possible value of \$abc\$ among all such Pythagorean triplets, and if there is no such Pythagorean triplet print −1. However, I feel uncomfortable about my...
This program works, but it's pretty clunky and fragile. I want to make it more dynamic / solid. For instance some of the functionality depends on the order I entered things into an ArrayList, that seems to me to be an example of a terribly odious smelly code. //These structures hold the word list & corresponding flag...
This is my second try at writing Ruby. Stylistic feedback is very much appreciated. The problem: 2048 is played on a simple 4 x 4 grid with tiles that slide smoothly when a player moves them. For each movement, the player can choose to move all tiles in 4 directions, left, right, up, and down, as far as possib...
The actions I'm wondering about are members, add_student, and remove_student. They work just fine, but they aren't RESTful and it feels like they should be handled (perhaps) by the StudentsController. Note that members and show are the same. The only difference is that the members.html.erb view iterates over and displ...
This is part of a script that I use for porting a TWRP theme from one resolution to another, respectively portrait to portrait and landscape to landscape. In this function entirely, it focuses on the images. What I am not showing is irrelevant since it focuses on porting the XML files. I compiled GraphicsMagick for ARM...
I am currently using an enum in my Android application to display time periods: Weekly Bi-Weekly Monthly Quarterly Yearly I created the enum like this, because I wanted to know the description, and (roughly) number of days: public enum SpendingPeriods { WEEKLY("Weekly", 7), BIWEEKLY("Bi-Weekly", 14), MONT...
I wrote this class recently to better structure and handle MySQLi related interactions with PHP and would love to get some feedback. <?php /* * simpleMysqli * * @usage This class is meant to be extended, with * the resulting class setting the $table parameter * in it's __construct(). * */ class simpleMysqli ex...
Our team is developing an educational website using ASP.NET webforms. We designed DAL & BAL classes and now I have some questions: Are DAL & BAL designed well? Would it be better using ORM (like EF) instead of using our own classes? (ORM is slow, but I'm not sure) Should we ignore BAL and only have DAL (2 layers in...
Following from a discussion with others on StackOverflow concerning the issue with getline not limiting input and happily reallocating until enough space for a sizable nefarious string, I picked around at a substitute that I could put in place that mimics getline's behavior. The primary objective was to enforce a leng...
I'm currently porting a web-based POS system to Android. The Android version uses NavigationDrawer to navigate between menus. What I need a code review on is my current approach in loading fragments upon selected an item from navigation drawer. I'm using reflection to achieve my case. MainActivity.java @Override pu...
I tried my hand at a grade XII Board exam program: Given two positive numbers M and N, such that M is between 100 and 10000 and N is less than 100, find the smallest integer that is greater than M and whose digits add up to N. For example, if M = 100 and N = 11, the minimum number is 119 whose digits add up to N. Writ...
I have the following code which is supposed to insert a row into a DB table "clicks" (consisting of 1 Primary AI column "id" and another column "user" which contains the user's session ID) upon clicking the Like button. For each user assuming they have a session ID set from a login I would like to return to them their ...
Follow-up up on Parsing oscilloscope binary data. I wrote a simple parser for Tektronix's internal file format .isf. I revised my code to the following: import numpy as np import os.path def parse_curve(isf_file): """ Reads one tektronix .isf file and returns a dictionary containing all tags as keys. The ...
Assignment from here Q6. Define a function shuffle that takes a list with an even number of elements (cards) and creates a new list that interleaves the elements of the first half with the elements of the second half: def card(n): """Return the playing card type for a positive n <= 13.""" assert type(n) == in...
The following spider will grab some driver links, OS version, and the name. All the info is in a table class, but some pages might be a little different in the location and Number of cells in each row. I can't post the HTML page, but the main problem I'm facing now is that sometimes the number of the row I need is in c...
for (int i = 0; i < keyList.Count; i++) { if (oldDic.ContainsKey(keyList[i].ToString())) { if (newDic[keyList[i].ToString()].ToString() == oldDic[keyList[i].ToString()].ToString()) { //ReminderBackupLog("Same"); } else { isChnagedSectionFields = "Y...
Before implementing a GUI I tried performing it at CLI first and I also tried to implement it by using calling methods to another class. BinaryConversion class: import java.io.IOException; import static java.lang.System.in; import java.util.InputMismatchException; import java.util.Scanner; public class BinaryConversio...
I have a monolithic script that powers this form: Here it is: $(function() { // Functions function attainDistinctTags(value) { var tags = value.split(','); tags = tags.filter(function(tag) { return /\S/.test(tag) }); tags = tags.filter(function(item, pos, self) { return self.indexOf(item) == pos; }); ...
I'm just wanting some input on to how others would approach this problem. I am learning and wish to gain insight on others techniques. Be as critical as you need. I want to learn. I feel this code is sloppy and the logic is confusing. /* Pig Latin Write a program that reads a sentence as input and converts ...
This directive works fine but I have the feeling that I'm not doing it the "angular way" with .attr('hide', 'true'). Is there a better way to show or hide elements from a directive? app.directive('myRandomshow', function() { // Show a random element from child elements function randomIntFromInterval(min, max) { ...
I recently came across this code snippet, and I have tried to change it. this.lblCheck.Visible = false; this.lblBackup.Visible = false; this.txtEmpNo.Visible = false; this.CheckButton.Enabled = false; if (matchedCode) { if (checkBackdatedLeave) { this.lblBackup.Visible = true; this.txtEmpNo.V...
Since i'm still learning C# i've made an exercise but it seems like i'm using the same code over and over again. I do realize I have to use a helper method to get rid of the 'useless' code. How can I put my for loops into a helper method ? using System; using System.Collections.Generic; using System.Linq; using System....
I have such method: @SuppressWarnings("unchecked") public static <T, K> K[] toArray(ITemplateCommand<T, K> command, List<T> templates) { if (null == templates) { return (K[]) Array.newInstance(command.getClassOfK(), 0); } K[] array = (K[]) Array.newInstance(command.getClassOfK(), templates.size()); ...