not limit the right of a defendant to interpose counterclaims to an action brought on a contract, but gives the right to interpose counterclaims in an action brought to recover damages for a tort, if the causes of actions set out in the complaint and in the answer arise out of the same contract or transaction, or relate to the same subject. Mor does the subdivision provide that the cause of action set up as a counterclaim must arise out of a contract, but it authorizes the interposition of causes of actions arising out ol torts as counterclaims. The theory of the Code is to authorize all connected causes of action, whether arising out of contracts or torts, to be litigated in the same action. The cause of action set out in the complaint arises out of the alleged tortious breach, -by the defendant, of the written contract of April 1, 1892, to wit, the collection and conversion to his own use of money which, by that contract, he had no right to collect, but which should have been paid by the purchasers of goods to the plaintiff The plaintiff, as the foundation- for his cause of action, alleges what he asserts is the legal effect of the contract of April 1, 1892, which he must introduce in evidence before he will be permitted to give evidence tending to show that the defendant wrongfully broke it. All of the counterclaims arise out of the alleged nonperformance by the plaintiff of that contract, and, besides, they are connected with the subject of the action. In other words, the cause of action set out in the complaint and the causes of action set out in the answer as counterclaims arise out of the alleged breach of the same contract, and the causes of action set out in the answer may be pleaded as counterclaims under § 501. In
Carpenter v.
Manhattan Life Ins. Co., 93 N. Y. 552 , the doctrine that a counterclaim cannot be allowed in an action to recover damages for a tort was repudiated. That case arose out of the following facts : The defendant held the first mortgage on a farm on which the plaintiff held the second mortgage. The plaintiff, while in possession of the farm under his second mortgage, cut 65 cords of wood, but before it was taken away the defendant acquired possession of the farm through the foreclosure of its mortgage, on which foreclosure there was a large deficiency. The defendant refused to permit the plaintiff to remove the wood, and, in an action to recover damages for its conversion, was permitted to set up, as a counterclaim, that the farm was inadequate security for the first mortgage, and that the mortgagor was insolvent, which facts the plaintiff well knew, and, being in possession, wrongfully committed waste by cutting the wood, to the injury of the farm of $500. In discussing the question, it was said that the transaction set out in the complaint was the conversion of the wood, and that the counterclaim did not arise out of that transaction, but it was held that it was connected with the subject of the action. The court said : “The counterclaim must have such a relation to, and connection with, the subject of the action, that it will be just' and equitable that the controversy between the parties as to the matters alleged in the complaint and in the counterclaim should be settled in one action by one litigation, and that the claim of the one should be offset against, or applied upon, the claim of the other.”